From fae5033a01b78d3e8f23c1c9438bc5534dfe0fa3 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 3 May 2018 08:59:19 -0400 Subject: Make podman commit to localhost rather then docker.io Signed-off-by: Daniel J Walsh Closes: #715 Approved by: mheon --- .../projectatomic/buildah/imagebuildah/build.go | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'vendor/github.com/projectatomic/buildah/imagebuildah') diff --git a/vendor/github.com/projectatomic/buildah/imagebuildah/build.go b/vendor/github.com/projectatomic/buildah/imagebuildah/build.go index 81e8108a0..dd8421807 100644 --- a/vendor/github.com/projectatomic/buildah/imagebuildah/build.go +++ b/vendor/github.com/projectatomic/buildah/imagebuildah/build.go @@ -23,6 +23,7 @@ import ( "github.com/openshift/imagebuilder" "github.com/pkg/errors" "github.com/projectatomic/buildah" + "github.com/projectatomic/buildah/util" "github.com/sirupsen/logrus" ) @@ -623,22 +624,25 @@ func (b *Executor) Execute(ib *imagebuilder.Builder, node *parser.Node) error { // the name if there is one, generating a unique ID-based one otherwise. func (b *Executor) Commit(ctx context.Context, ib *imagebuilder.Builder) (err error) { var imageRef types.ImageReference + if b.output != "" { imageRef, err = alltransports.ParseImageName(b.output) if err != nil { - imageRef2, err2 := is.Transport.ParseStoreReference(b.store, b.output) - if err2 == nil { - imageRef = imageRef2 - err = nil - } else { - err = err2 + candidates := util.ResolveName(b.output, "", b.systemContext, b.store) + if len(candidates) == 0 { + return errors.Errorf("error parsing target image name %q", b.output) + } + imageRef2, err2 := is.Transport.ParseStoreReference(b.store, candidates[0]) + if err2 != nil { + return errors.Wrapf(err, "error parsing target image name %q", b.output) } + imageRef = imageRef2 } } else { imageRef, err = is.Transport.ParseStoreReference(b.store, "@"+stringid.GenerateRandomID()) - } - if err != nil { - return errors.Wrapf(err, "error parsing reference for image to be written") + if err != nil { + return errors.Wrapf(err, "error parsing reference for image to be written") + } } if ib.Author != "" { b.builder.SetMaintainer(ib.Author) @@ -689,7 +693,14 @@ func (b *Executor) Commit(ctx context.Context, ib *imagebuilder.Builder) (err er PreferredManifestType: b.outputFormat, IIDFile: b.iidfile, } - return b.builder.Commit(ctx, imageRef, options) + imgID, err := b.builder.Commit(ctx, imageRef, options) + if err != nil { + return err + } + if options.IIDFile == "" && imgID != "" { + fmt.Printf("%s\n", imgID) + } + return nil } // Build takes care of the details of running Prepare/Execute/Commit/Delete -- cgit v1.2.3-54-g00ecf