Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manifest: ListUpdate add imgspecv1.Platform field #2029

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/manifest/docker_schema2_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/manifest/docker_schema2_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Platform)

// Create a fresh list
list, err = ListFromBlob(validManifest, GuessMIMEType(validManifest))
Expand Down
1 change: 1 addition & 0 deletions internal/manifest/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type ListUpdate struct {
Digest digest.Digest
Size int64
MediaType string
Platform *imgspecv1.Platform // read-only field: may be set by Instance(), ignored by UpdateInstance()
}

type ListOp int
Expand Down
1 change: 1 addition & 0 deletions internal/manifest/oci_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (index *OCI1IndexPublic) Instance(instanceDigest digest.Digest) (ListUpdate
Digest: manifest.Digest,
Size: manifest.Size,
MediaType: manifest.MediaType,
Platform: manifest.Platform,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a bit safer to make a clone instead of providing a pointer to our data, but, meh, we can deal with that if it breaks I guess.

}, nil
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/manifest/oci_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.Platform)

// Create a fresh list
list, err = ListFromBlob(validManifest, GuessMIMEType(validManifest))
Expand Down