Skip to content

Commit

Permalink
Merge pull request #2029 from flouthoc/listupdate-add-platform
Browse files Browse the repository at this point in the history
manifest: `ListUpdate` add `imgspecv1.Platform` field
  • Loading branch information
mtrmac authored Jul 7, 2023
2 parents 1a2230a + a243961 commit bbd40dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
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,
}, 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

0 comments on commit bbd40dd

Please sign in to comment.