fix: buildx multiarch image date and history not shown (#309)

Support images created with buildx and `--provenance true`

fixes #309
This commit is contained in:
Joxit
2023-05-20 02:04:22 +02:00
parent d2222bef05
commit 9ebbbc3518
5 changed files with 1305 additions and 4 deletions

View File

@@ -14,10 +14,26 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Http } from './http';
import { isDigit, eventTransfer, ERROR_CAN_NOT_READ_CONTENT_DIGEST } from './utils';
import { Http } from './http.js';
import { eventTransfer, ERROR_CAN_NOT_READ_CONTENT_DIGEST } from './utils.js';
import observable from '@riotjs/observable';
export const supportListManifest = (response) => {
if (response.mediaType === 'application/vnd.docker.distribution.manifest.list.v2+json') {
return true;
}
if (response.mediaType === 'application/vnd.oci.image.index.v1+json' && Array.isArray(response.manifests)) {
return !response.manifests.some(({ mediaType }) => mediaType !== 'application/vnd.oci.image.manifest.v1+json');
}
return false;
};
export const filterWrongManifests = (response) => {
return response.manifests.filter(
({ annotations }) => !annotations || annotations['vnd.docker.reference.type'] !== 'attestation-manifest'
);
};
export class DockerImage {
constructor(name, tag, { list, registryUrl, onNotify, onAuthentication, useControlCacheHeader }) {
this.name = name;
@@ -73,8 +89,8 @@ export class DockerImage {
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.opts.list) {
self.trigger('list', response);
if (supportListManifest(response) && self.opts.list) {
self.trigger('list', filterWrongManifests(response));
const manifest = response.manifests[0];
const image = new DockerImage(self.name, manifest.digest, { ...self.opts, list: false });
eventTransfer(image, self);