Skip to content

Commit

Permalink
Populate the platform information when calling the References() metho…
Browse files Browse the repository at this point in the history
…d of manifest list

Populate the platform information when calling the References() method of manifest list

Signed-off-by: Wenkai Yin <[email protected]>
  • Loading branch information
ywk253100 committed Mar 2, 2021
1 parent 90e62ac commit 1a059fe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions manifest/manifestlist/manifestlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ func (m ManifestList) References() []distribution.Descriptor {
dependencies := make([]distribution.Descriptor, len(m.Manifests))
for i := range m.Manifests {
dependencies[i] = m.Manifests[i].Descriptor
dependencies[i].Platform = &v1.Platform{
Architecture: m.Manifests[i].Platform.Architecture,
OS: m.Manifests[i].Platform.OS,
OSVersion: m.Manifests[i].Platform.OSVersion,
OSFeatures: m.Manifests[i].Platform.OSFeatures,
Variant: m.Manifests[i].Platform.Variant,
}
}

return dependencies
Expand Down
24 changes: 24 additions & 0 deletions manifest/manifestlist/manifestlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ func TestManifestList(t *testing.T) {
t.Fatalf("unexpected number of references: %d", len(references))
}
for i := range references {
platform := manifestDescriptors[i].Platform
expectedPlatform := &v1.Platform{
Architecture: platform.Architecture,
OS: platform.OS,
OSFeatures: platform.OSFeatures,
OSVersion: platform.OSVersion,
Variant: platform.Variant,
}
if !reflect.DeepEqual(references[i].Platform, expectedPlatform) {
t.Fatalf("unexpected value %d returned by References: %v", i, references[i])
}
references[i].Platform = nil
if !reflect.DeepEqual(references[i], manifestDescriptors[i].Descriptor) {
t.Fatalf("unexpected value %d returned by References: %v", i, references[i])
}
Expand Down Expand Up @@ -247,6 +259,18 @@ func TestOCIImageIndex(t *testing.T) {
t.Fatalf("unexpected number of references: %d", len(references))
}
for i := range references {
platform := manifestDescriptors[i].Platform
expectedPlatform := &v1.Platform{
Architecture: platform.Architecture,
OS: platform.OS,
OSFeatures: platform.OSFeatures,
OSVersion: platform.OSVersion,
Variant: platform.Variant,
}
if !reflect.DeepEqual(references[i].Platform, expectedPlatform) {
t.Fatalf("unexpected value %d returned by References: %v", i, references[i])
}
references[i].Platform = nil
if !reflect.DeepEqual(references[i], manifestDescriptors[i].Descriptor) {
t.Fatalf("unexpected value %d returned by References: %v", i, references[i])
}
Expand Down

0 comments on commit 1a059fe

Please sign in to comment.