diff --git a/internal/manifest/docker_schema2_list.go b/internal/manifest/docker_schema2_list.go index 516ca7ac94..f126d302bc 100644 --- a/internal/manifest/docker_schema2_list.go +++ b/internal/manifest/docker_schema2_list.go @@ -61,6 +61,13 @@ func (list *Schema2ListPublic) Instance(instanceDigest digest.Digest) (ListUpdat Digest: manifest.Digest, Size: manifest.Size, MediaType: manifest.MediaType, + platform: imgspecv1.Platform{ + OS: manifest.Platform.OS, + Architecture: manifest.Platform.Architecture, + OSVersion: manifest.Platform.OSVersion, + OSFeatures: manifest.Platform.OSFeatures, + Variant: manifest.Platform.Variant, + }, }, nil } } diff --git a/internal/manifest/docker_schema2_list_test.go b/internal/manifest/docker_schema2_list_test.go index 6597bc9771..c4d3fa6192 100644 --- a/internal/manifest/docker_schema2_list_test.go +++ b/internal/manifest/docker_schema2_list_test.go @@ -55,6 +55,8 @@ func TestSchema2ListEditInstances(t *testing.T) { require.NoError(t, err) assert.Equal(t, "something", instance.MediaType) assert.Equal(t, int64(32), instance.Size) + // platform must match with instance platform set in `v2list.manifest.json` for the first instance + assert.Equal(t, imgspecv1.Platform{Architecture: "ppc64le", OS: "linux", OSVersion: "", OSFeatures: []string(nil), Variant: ""}, instance.GetPlatform()) // Create a fresh list list, err = ListFromBlob(validManifest, GuessMIMEType(validManifest)) diff --git a/internal/manifest/list.go b/internal/manifest/list.go index 8786324ea4..ba45413ee2 100644 --- a/internal/manifest/list.go +++ b/internal/manifest/list.go @@ -68,6 +68,12 @@ type ListUpdate struct { Digest digest.Digest Size int64 MediaType string + platform imgspecv1.Platform // stores platform for the instance, read-only field +} + +// Allows to access private read-only field `platform`. +func (listUpdate ListUpdate) GetPlatform() imgspecv1.Platform { + return listUpdate.platform } type ListOp int diff --git a/internal/manifest/oci_index.go b/internal/manifest/oci_index.go index fd251d9512..7c00cac2c1 100644 --- a/internal/manifest/oci_index.go +++ b/internal/manifest/oci_index.go @@ -57,6 +57,7 @@ func (index *OCI1IndexPublic) Instance(instanceDigest digest.Digest) (ListUpdate Digest: manifest.Digest, Size: manifest.Size, MediaType: manifest.MediaType, + platform: *manifest.Platform, }, nil } } diff --git a/internal/manifest/oci_index_test.go b/internal/manifest/oci_index_test.go index 2e602c52d3..19dbb15aff 100644 --- a/internal/manifest/oci_index_test.go +++ b/internal/manifest/oci_index_test.go @@ -77,6 +77,8 @@ func TestOCI1EditInstances(t *testing.T) { require.NoError(t, err) assert.Equal(t, "something", instance.MediaType) assert.Equal(t, int64(32), instance.Size) + // platform must match with what was set in `ociv1.image.index.json` for the first instance + assert.Equal(t, imgspecv1.Platform{Architecture: "ppc64le", OS: "linux", OSVersion: "", OSFeatures: []string(nil), Variant: ""}, instance.GetPlatform()) // Create a fresh list list, err = ListFromBlob(validManifest, GuessMIMEType(validManifest))