feat(multi-arch): add header for list and fill history with the first arch

This commit is contained in:
Joxit 2020-06-09 19:47:09 +02:00
parent 42f19fcef7
commit f8c5010fd1
No known key found for this signature in database
GPG key ID: F526592B8E012263
3 changed files with 19 additions and 3 deletions

View file

@ -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);
})
}

View file

@ -118,9 +118,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
}
});
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();
};

View file

@ -123,7 +123,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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);
};