Skip to content

Commit

Permalink
feat(oci): support specifying the manifest digest when pushing it
Browse files Browse the repository at this point in the history
See opencontainers/distribution-spec#494 and related work

Signed-off-by: Andrei Aaron <[email protected]>
  • Loading branch information
andaaron committed Jul 24, 2024
1 parent a7ab16b commit 3702fe9
Show file tree
Hide file tree
Showing 26 changed files with 473 additions and 220 deletions.
39 changes: 4 additions & 35 deletions pkg/api/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11198,13 +11198,7 @@ func TestSupportedDigestAlgorithms(t *testing.T) {

client := resty.New()

// The server picks canonical digests when tags are pushed
// See https:/opencontainers/distribution-spec/issues/494
// It would be nice to be able to push tags with other digest algorithms and verify those are returned
// but there is no way to specify a client preference
// so all we can do is verify the correct algorithm is returned

expectedDigestStr := image.DigestForAlgorithm(godigest.Canonical).String()
expectedDigestStr := image.DigestForAlgorithm(godigest.SHA512).String()

verifyReturnedManifestDigest(t, client, baseURL, name, tag, expectedDigestStr)
verifyReturnedManifestDigest(t, client, baseURL, name, expectedDigestStr, expectedDigestStr)
Expand Down Expand Up @@ -11238,13 +11232,7 @@ func TestSupportedDigestAlgorithms(t *testing.T) {

client := resty.New()

// The server picks canonical digests when tags are pushed
// See https:/opencontainers/distribution-spec/issues/494
// It would be nice to be able to push tags with other digest algorithms and verify those are returned
// but there is no way to specify a client preference
// so all we can do is verify the correct algorithm is returned

expectedDigestStr := image.DigestForAlgorithm(godigest.Canonical).String()
expectedDigestStr := image.DigestForAlgorithm(godigest.SHA384).String()

verifyReturnedManifestDigest(t, client, baseURL, name, tag, expectedDigestStr)
verifyReturnedManifestDigest(t, client, baseURL, name, expectedDigestStr, expectedDigestStr)
Expand All @@ -11266,18 +11254,10 @@ func TestSupportedDigestAlgorithms(t *testing.T) {

client := resty.New()

// The server picks canonical digests when tags are pushed
// See https:/opencontainers/distribution-spec/issues/494
// It would be nice to be able to push tags with other digest algorithms and verify those are returned
// but there is no way to specify a client preference
// so all we can do is verify the correct algorithm is returned
expectedDigestStr := multiarch.DigestForAlgorithm(godigest.Canonical).String()
expectedDigestStr := multiarch.DigestForAlgorithm(godigest.SHA512).String()

verifyReturnedManifestDigest(t, client, baseURL, name, tag, expectedDigestStr)
verifyReturnedManifestDigest(t, client, baseURL, name, expectedDigestStr, expectedDigestStr)

// While the expected multiarch manifest digest is always using the canonical algorithm
// the sub-imgage manifest digest can use any algorith
verifyReturnedManifestDigest(t, client, baseURL, name,
subImage1.ManifestDescriptor.Digest.String(), subImage1.ManifestDescriptor.Digest.String())
verifyReturnedManifestDigest(t, client, baseURL, name,
Expand All @@ -11303,9 +11283,6 @@ func TestSupportedDigestAlgorithms(t *testing.T) {

expectedDigestStr := multiarch.DigestForAlgorithm(godigest.SHA512).String()
verifyReturnedManifestDigest(t, client, baseURL, name, expectedDigestStr, expectedDigestStr)

// While the expected multiarch manifest digest is always using the canonical algorithm
// the sub-imgage manifest digest can use any algorith
verifyReturnedManifestDigest(t, client, baseURL, name,
subImage1.ManifestDescriptor.Digest.String(), subImage1.ManifestDescriptor.Digest.String())
verifyReturnedManifestDigest(t, client, baseURL, name,
Expand All @@ -11328,18 +11305,10 @@ func TestSupportedDigestAlgorithms(t *testing.T) {

client := resty.New()

// The server picks canonical digests when tags are pushed
// See https:/opencontainers/distribution-spec/issues/494
// It would be nice to be able to push tags with other digest algorithms and verify those are returned
// but there is no way to specify a client preference
// so all we can do is verify the correct algorithm is returned
expectedDigestStr := multiarch.DigestForAlgorithm(godigest.Canonical).String()
expectedDigestStr := multiarch.DigestForAlgorithm(godigest.SHA384).String()

verifyReturnedManifestDigest(t, client, baseURL, name, tag, expectedDigestStr)
verifyReturnedManifestDigest(t, client, baseURL, name, expectedDigestStr, expectedDigestStr)

// While the expected multiarch manifest digest is always using the canonical algorithm
// the sub-imgage manifest digest can use any algorith
verifyReturnedManifestDigest(t, client, baseURL, name,
subImage1.ManifestDescriptor.Digest.String(), subImage1.ManifestDescriptor.Digest.String())
verifyReturnedManifestDigest(t, client, baseURL, name,
Expand Down
Loading

0 comments on commit 3702fe9

Please sign in to comment.