Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"makefile.configureOnOpen": false
}
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

(nothing yet)

## 3.5.0

- Add support for multi-architecture repositories.

## 3.4.0

- TRITON-2403 Add support for docker OCI manifest format
Expand Down
40 changes: 40 additions & 0 deletions lib/registry-client-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,19 @@ function digestFromManifestStr(manifestStr) {
}


// Helper to select manifest from manifest list by os and architecture
function selectManifestFromList(manifestList, opts) {
var arch = opts.architecture || process.arch;
var os = opts.os || 'linux'; // process.platform;
for (var i = 0; i < manifestList.manifests.length; i++) {
var m = manifestList.manifests[i];
if (m.platform && m.platform.architecture === arch && m.platform.os === os) {
return m;
}
}
return null;
}


// --- RegistryClientV2

Expand Down Expand Up @@ -2088,7 +2101,34 @@ RegistryClientV2.prototype.blobUpload = function blobUpload(opts, cb) {
});
};

/*
* Get an image manifest for a specific platform. `ref` is either a tag or a digest.
* `arch` is the requested architecture (defaults to current architecture),
* `os` is the requested OS (defaults to 'linux').
*/

RegistryClientV2.prototype.getManifestForPlatform = function (opts, cb) {
var self = this;
self.getManifest({ref: opts.ref, maxSchemaVersion: 2, acceptManifestLists: true}, function (err, manifest, res, manifestStr) {
if (err) return cb(err);
// Check if this is a manifest list
if (manifest.mediaType &&
(
manifest.mediaType === MEDIATYPE_MANIFEST_LIST_V2 ||
manifest.mediaType === MEDIATYPE_OCI_MANIFEST_LIST_V1
)
) {
var desc = selectManifestFromList(manifest, opts);
if (!desc) {
return cb(new Error('No manifest found for requested platform'));
}
// Fetch the referenced manifest
self.getManifest({ref: desc.digest, maxSchemaVersion: 2}, cb);
} else {
cb(null, manifest, res, manifestStr);
}
});
};

// --- Exports

Expand Down
Loading