diff --git a/src/scripts/utils.js b/src/scripts/utils.js index a30e7a4..8623dfa 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.js @@ -119,3 +119,9 @@ registryUI.stripHttps = function (url) { } return url.replace(/^https?:\/\//, ''); }; + +registryUI.eventTransfer = function(from, to) { + from.on('*', function(event, param) { + to.trigger(event, param); + }) +} \ No newline at end of file diff --git a/src/tags/app.tag b/src/tags/app.tag index 3e3c179..9c7750a 100644 --- a/src/tags/app.tag +++ b/src/tags/app.tag @@ -118,9 +118,10 @@ along with this program. If not, see . return char >= '0' && char <= '9'; }; - registryUI.DockerImage = function(name, tag) { + registryUI.DockerImage = function(name, tag, list) { this.name = name; this.tag = tag; + this.list = list; this.chars = 0; riot.observable(this); this.on('get-size', function() { @@ -192,6 +193,14 @@ along with this program. If not, see . oReq.addEventListener('loadend', function() { if (this.status == 200 || this.status == 202) { const response = JSON.parse(this.responseText); + if (response.mediaType === 'application/vnd.docker.distribution.manifest.list.v2+json') { + self.trigger('list', response); + const manifest = response.manifests[0]; + const image = new registryUI.DockerImage(self.name, manifest.digest) + registryUI.eventTransfer(image, self) + image.fillInfo() + return; + } self.size = response.layers.reduce(function(acc, e) { return acc + e.size; }, 0); @@ -214,7 +223,8 @@ along with this program. If not, see . } }); oReq.open('GET', registryUI.url() + '/v2/' + self.name + '/manifests/' + self.tag); - oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.manifest.v1+json'); + oReq.setRequestHeader('Accept', 'application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.manifest.v1+json' + + (self.list ? ', application/vnd.docker.distribution.manifest.list.v2+json' : '')); oReq.send(); }; diff --git a/src/tags/tag-history.tag b/src/tags/tag-history.tag index 78c24a0..7636777 100644 --- a/src/tags/tag-history.tag +++ b/src/tags/tag-history.tag @@ -123,7 +123,7 @@ along with this program. If not, see . window.scrollTo(0, 0); return processBlobs(blobs); } - const image = new registryUI.DockerImage(registryUI.taghistory.image, registryUI.taghistory.tag); + const image = new registryUI.DockerImage(registryUI.taghistory.image, registryUI.taghistory.tag, true); image.fillInfo() image.on('blobs', processBlobs); };