From 22422cc399e6465fbe527ef396ade231a0daf280 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Mon, 13 Feb 2017 11:44:47 -0500 Subject: [PATCH] Update to match API changes in dependencies Signed-off-by: Nalin Dahyabhai --- config.go | 23 +++++++++-------------- image.go | 13 +++++-------- pull.go | 3 ++- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/config.go b/config.go index 589b75e6..47239ea6 100644 --- a/config.go +++ b/config.go @@ -11,12 +11,8 @@ import ( ) func copyDockerImageConfig(dimage *docker.Image) (ociv1.Image, error) { - created, err := dimage.Created.UTC().MarshalText() - if err != nil { - created = []byte{} - } image := ociv1.Image{ - Created: string(created), + Created: dimage.Created.UTC(), Author: dimage.Author, Architecture: dimage.Architecture, OS: dimage.OS, @@ -50,12 +46,9 @@ func copyDockerImageConfig(dimage *docker.Image) (ociv1.Image, error) { } } for _, history := range dimage.History { - created, err := history.Created.UTC().MarshalText() - if err != nil { - created = []byte{} - } + created := history.Created.UTC() ohistory := ociv1.History{ - Created: string(created), + Created: created, CreatedBy: history.CreatedBy, Author: history.Author, Comment: history.Comment, @@ -81,10 +74,7 @@ func (b *Builder) updatedConfig() []byte { } } } - createdBytes, err := time.Now().UTC().MarshalText() - if err == nil { - image.Created = string(createdBytes) - } + image.Created = time.Now().UTC() if image.Architecture == "" { image.Architecture = runtime.GOARCH } @@ -103,6 +93,11 @@ func (b *Builder) updatedConfig() []byte { if b.User != "" { image.Config.User = b.User } + if len(b.Volumes) > 0 { + for _, volSpec := range b.Volumes { + image.Config.Volumes[volSpec] = struct{}{} + } + } if b.Workdir != "" { image.Config.WorkingDir = b.Workdir } diff --git a/image.go b/image.go index b6b19e45..79da6196 100644 --- a/image.go +++ b/image.go @@ -85,10 +85,7 @@ func (i *containerImageRef) NewImageSource(sc *types.SystemContext, manifestType } logrus.Debugf("layer list: %q", layers) - createdDate, err := time.Now().UTC().MarshalText() - if err != nil { - return nil, err - } + created := time.Now().UTC() path, err := ioutil.TempDir(os.TempDir(), Package) if err != nil { @@ -149,7 +146,7 @@ func (i *containerImageRef) NewImageSource(sc *types.SystemContext, manifestType if i.compression != archive.Uncompressed { switch i.compression { case archive.Gzip: - mediaType = MediaTypeImageLayerGzip + mediaType = v1.MediaTypeImageLayerGzip logrus.Debugf("compressing layer %q with gzip", layerID) case archive.Bzip2: logrus.Debugf("compressing layer %q with bzip2", layerID) @@ -178,7 +175,7 @@ func (i *containerImageRef) NewImageSource(sc *types.SystemContext, manifestType err = os.Rename(filepath.Join(path, "layer"), filepath.Join(path, destHasher.Digest().String())) layerDescriptor := v1.Descriptor{ MediaType: mediaType, - Digest: destHasher.Digest().String(), + Digest: destHasher.Digest(), Size: size, } manifest.Layers = append(manifest.Layers, layerDescriptor) @@ -187,7 +184,7 @@ func (i *containerImageRef) NewImageSource(sc *types.SystemContext, manifestType } news := v1.History{ - Created: string(createdDate), + Created: created, CreatedBy: i.createdBy, Author: image.Author, EmptyLayer: false, @@ -201,7 +198,7 @@ func (i *containerImageRef) NewImageSource(sc *types.SystemContext, manifestType logrus.Debugf("config = %s\n", config) i.config = config - manifest.Config.Digest = digest.FromBytes(config).String() + manifest.Config.Digest = digest.FromBytes(config) manifest.Config.Size = int64(len(config)) mfest, err := json.Marshal(&manifest) diff --git a/pull.go b/pull.go index 7d4cb969..1f6f24c8 100644 --- a/pull.go +++ b/pull.go @@ -5,6 +5,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/containers/image/copy" + "github.com/containers/image/docker/reference" "github.com/containers/image/signature" is "github.com/containers/image/storage" "github.com/containers/image/transports" @@ -30,7 +31,7 @@ func pullImage(store storage.Store, options BuilderOptions, sc *types.SystemCont } if ref := srcRef.DockerReference(); ref != nil { - name = ref.FullName() + name = reference.Domain(ref) + "/" + reference.Path(ref) } destRef, err := is.Transport.ParseStoreReference(store, name)