From 2e783a367da4b86e4b8757b89edfbf41ef86e6d2 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Fri, 8 Dec 2017 16:07:03 -0500 Subject: [PATCH] Set the explicitly-settable image digest Now that the storage library lets us set the digest of an image, set it to the digest of a preprocessed copy of the image's digest, in case it differs from the manifest as we store it. Signed-off-by: Nalin Dahyabhai --- storage/storage_image.go | 9 +++++---- vendor.conf | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/storage/storage_image.go b/storage/storage_image.go index 0240aaff2a..a085adddf4 100644 --- a/storage/storage_image.go +++ b/storage/storage_image.go @@ -568,12 +568,13 @@ func (s *storageImageDestination) Commit() error { } // If one of those blobs was a configuration blob, then we can try to dig out the date when the image // was originally created, in case we're just copying it. If not, no harm done. - var options *storage.ImageOptions + options := &storage.ImageOptions{} if inspect, err := man.Inspect(s.getConfigBlob); err == nil { logrus.Debugf("setting image creation date to %s", inspect.Created) - options = &storage.ImageOptions{ - CreationDate: inspect.Created, - } + options.CreationDate = inspect.Created + } + if manifestDigest, err := manifest.Digest(s.manifest); err == nil { + options.Digest = manifestDigest } // Create the image record, pointing to the most-recently added layer. intendedID := s.imageRef.id diff --git a/vendor.conf b/vendor.conf index 7e74f55371..e2fe81cc44 100644 --- a/vendor.conf +++ b/vendor.conf @@ -1,5 +1,5 @@ github.com/sirupsen/logrus v1.0.0 -github.com/containers/storage 138cddaf9d6b3910b18de44a017417f60bff4e66 +github.com/containers/storage manifest-digest https://github.com/nalind/storage github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 github.com/docker/docker-credential-helpers d68f9aeca33f5fd3f08eeae5e9d175edf4e731d1 github.com/docker/distribution 5f6282db7d65e6d72ad7c2cc66310724a57be716