diff --git a/directory/directory_dest.go b/directory/directory_dest.go index 5cafd267..e99186b0 100644 --- a/directory/directory_dest.go +++ b/directory/directory_dest.go @@ -239,6 +239,9 @@ func (d *dirImageDestination) PutSignatures(ctx context.Context, signatures [][] } // Commit marks the process of storing the image as successful and asks for the image to be persisted. +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. // WARNING: This does not have any transactional semantics: // - Uploaded data MAY be visible to others before Commit() is called // - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) diff --git a/directory/directory_test.go b/directory/directory_test.go index fdb0ce68..0861786f 100644 --- a/directory/directory_test.go +++ b/directory/directory_test.go @@ -42,7 +42,7 @@ func TestGetPutManifest(t *testing.T) { assert.NoError(t, err) err = dest.PutManifest(context.Background(), list, nil) assert.NoError(t, err) - err = dest.Commit(context.Background(), nil) + err = dest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) src, err := ref.NewImageSource(context.Background(), nil) @@ -71,7 +71,7 @@ func TestGetPutBlob(t *testing.T) { assert.Equal(t, types.PreserveOriginal, dest.DesiredLayerCompression()) info, err := dest.PutBlob(context.Background(), bytes.NewReader(blob), types.BlobInfo{Digest: digest.Digest("sha256:digest-test"), Size: int64(9)}, cache, false) assert.NoError(t, err) - err = dest.Commit(context.Background(), nil) + err = dest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) assert.Equal(t, int64(9), info.Size) assert.Equal(t, digest.FromBytes(blob), info.Digest) @@ -130,7 +130,7 @@ func TestPutBlobDigestFailure(t *testing.T) { _, err = dest.PutBlob(context.Background(), reader, types.BlobInfo{Digest: blobDigest, Size: -1}, cache, false) assert.Error(t, err) assert.Contains(t, digestErrorString, err.Error()) - err = dest.Commit(context.Background(), nil) + err = dest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) _, err = os.Lstat(blobPath) @@ -175,7 +175,7 @@ func TestGetPutSignatures(t *testing.T) { assert.NoError(t, err) err = dest.PutSignatures(context.Background(), signatures, &md) assert.NoError(t, err) - err = dest.Commit(context.Background(), nil) + err = dest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) src, err := ref.NewImageSource(context.Background(), nil) diff --git a/directory/directory_transport_test.go b/directory/directory_transport_test.go index 40f31fcf..50c5c1d6 100644 --- a/directory/directory_transport_test.go +++ b/directory/directory_transport_test.go @@ -160,7 +160,7 @@ func TestReferenceNewImage(t *testing.T) { require.NoError(t, err) err = dest.PutManifest(context.Background(), mFixture, nil) assert.NoError(t, err) - err = dest.Commit(context.Background(), nil) + err = dest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) img, err := ref.NewImage(context.Background(), nil) @@ -177,7 +177,7 @@ func TestReferenceNewImageNoValidManifest(t *testing.T) { defer dest.Close() err = dest.PutManifest(context.Background(), []byte(`{"schemaVersion":1}`), nil) assert.NoError(t, err) - err = dest.Commit(context.Background(), nil) + err = dest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) _, err = ref.NewImage(context.Background(), nil) diff --git a/docker/archive/dest.go b/docker/archive/dest.go index e874e02e..d4248db2 100644 --- a/docker/archive/dest.go +++ b/docker/archive/dest.go @@ -67,6 +67,9 @@ func (d *archiveImageDestination) Close() error { } // Commit marks the process of storing the image as successful and asks for the image to be persisted. +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. // WARNING: This does not have any transactional semantics: // - Uploaded data MAY be visible to others before Commit() is called // - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) diff --git a/docker/daemon/daemon_dest.go b/docker/daemon/daemon_dest.go index 88609b3d..c38ab355 100644 --- a/docker/daemon/daemon_dest.go +++ b/docker/daemon/daemon_dest.go @@ -128,6 +128,9 @@ func (d *daemonImageDestination) Reference() types.ImageReference { } // Commit marks the process of storing the image as successful and asks for the image to be persisted. +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. // WARNING: This does not have any transactional semantics: // - Uploaded data MAY be visible to others before Commit() is called // - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) diff --git a/docker/docker_image_dest.go b/docker/docker_image_dest.go index e11084dc..e4b68670 100644 --- a/docker/docker_image_dest.go +++ b/docker/docker_image_dest.go @@ -659,6 +659,9 @@ sigExists: } // Commit marks the process of storing the image as successful and asks for the image to be persisted. +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. // WARNING: This does not have any transactional semantics: // - Uploaded data MAY be visible to others before Commit() is called // - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) diff --git a/oci/archive/oci_dest.go b/oci/archive/oci_dest.go index c874eb77..ba99d7cb 100644 --- a/oci/archive/oci_dest.go +++ b/oci/archive/oci_dest.go @@ -129,6 +129,9 @@ func (d *ociArchiveImageDestination) PutSignatures(ctx context.Context, signatur } // Commit marks the process of storing the image as successful and asks for the image to be persisted +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. // after the directory is made, it is tarred up into a file and the directory is deleted func (d *ociArchiveImageDestination) Commit(ctx context.Context, unparsedToplevel types.UnparsedImage) error { if err := d.unpackedDest.Commit(ctx, unparsedToplevel); err != nil { diff --git a/oci/layout/oci_dest.go b/oci/layout/oci_dest.go index 1230e8ca..d1d06d64 100644 --- a/oci/layout/oci_dest.go +++ b/oci/layout/oci_dest.go @@ -303,6 +303,9 @@ func (d *ociImageDestination) PutSignatures(ctx context.Context, signatures [][] } // Commit marks the process of storing the image as successful and asks for the image to be persisted. +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. // WARNING: This does not have any transactional semantics: // - Uploaded data MAY be visible to others before Commit() is called // - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) diff --git a/oci/layout/oci_dest_test.go b/oci/layout/oci_dest_test.go index 7f111647..20b318c5 100644 --- a/oci/layout/oci_dest_test.go +++ b/oci/layout/oci_dest_test.go @@ -60,7 +60,7 @@ func TestPutBlobDigestFailure(t *testing.T) { _, err = dest.PutBlob(context.Background(), reader, types.BlobInfo{Digest: blobDigest, Size: -1}, cache, false) assert.Error(t, err) assert.Contains(t, digestErrorString, err.Error()) - err = dest.Commit(context.Background(), nil) + err = dest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) _, err = os.Lstat(blobPath) @@ -144,7 +144,7 @@ func putTestConfig(t *testing.T, ociRef ociReference, tmpDir string) { _, err = imageDest.PutBlob(context.Background(), bytes.NewReader(data), types.BlobInfo{Size: int64(len(data)), Digest: digest.FromBytes(data)}, cache, true) assert.NoError(t, err) - err = imageDest.Commit(context.Background(), nil) + err = imageDest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) paths := []string{} @@ -167,7 +167,7 @@ func putTestManifest(t *testing.T, ociRef ociReference, tmpDir string) { err = imageDest.PutManifest(context.Background(), data, nil) assert.NoError(t, err) - err = imageDest.Commit(context.Background(), nil) + err = imageDest.Commit(context.Background(), nil) // nil unparsedToplevel is invalid, we don’t currently use the value assert.NoError(t, err) paths := []string{} diff --git a/openshift/openshift.go b/openshift/openshift.go index 426046e6..6cd53070 100644 --- a/openshift/openshift.go +++ b/openshift/openshift.go @@ -506,6 +506,9 @@ sigExists: } // Commit marks the process of storing the image as successful and asks for the image to be persisted. +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. // WARNING: This does not have any transactional semantics: // - Uploaded data MAY be visible to others before Commit() is called // - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) diff --git a/storage/storage_image.go b/storage/storage_image.go index bab9826e..eb4d29c6 100644 --- a/storage/storage_image.go +++ b/storage/storage_image.go @@ -927,6 +927,13 @@ func (s *storageImageDestination) commitLayer(ctx context.Context, blob manifest return nil } +// Commit marks the process of storing the image as successful and asks for the image to be persisted. +// unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list +// if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the +// original manifest list digest, if desired. +// WARNING: This does not have any transactional semantics: +// - Uploaded data MAY be visible to others before Commit() is called +// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed) func (s *storageImageDestination) Commit(ctx context.Context, unparsedToplevel types.UnparsedImage) error { if len(s.manifest) == 0 { return errors.New("Internal error: storageImageDestination.Commit() called without PutManifest()") diff --git a/types/types.go b/types/types.go index 3e7abd34..c54f3d9f 100644 --- a/types/types.go +++ b/types/types.go @@ -334,6 +334,9 @@ type ImageDestination interface { // MUST be called after PutManifest (signatures may reference manifest contents). PutSignatures(ctx context.Context, signatures [][]byte, instanceDigest *digest.Digest) error // Commit marks the process of storing the image as successful and asks for the image to be persisted. + // unparsedToplevel contains data about the top-level manifest of the source (which may be a single-arch image or a manifest list + // if PutManifest was only called for the single-arch image with instanceDigest == nil), primarily to allow lookups by the + // original manifest list digest, if desired. // WARNING: This does not have any transactional semantics: // - Uploaded data MAY be visible to others before Commit() is called // - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)