diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2018-06-04 18:05:04 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-05 14:38:11 +0000 |
commit | 20cae6b502de7b41bb9a630f9ad8e15698e65437 (patch) | |
tree | c3591e5b8aea1089c8c2da9c6b485d994f50cd68 /vendor/github.com/projectatomic/buildah/new.go | |
parent | 14cf6d219eaff206be715197523578ef1f7ce878 (diff) | |
download | podman-20cae6b502de7b41bb9a630f9ad8e15698e65437.tar.gz podman-20cae6b502de7b41bb9a630f9ad8e15698e65437.tar.bz2 podman-20cae6b502de7b41bb9a630f9ad8e15698e65437.zip |
Vendor in latest buildah code
This fix the issues when you are trying to build from a non existant
image or the registries in registries.conf do not include the registry.
./bin/podman build -t dan -f Dockerfile.suse ~
STEP 1: FROM opensuse:tumbleweed
error creating build container: image "opensuse:tumbleweed" not found in /etc/containers/registries.conf registries: image not known
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
v#
Closes: #897
Approved by: mheon
Diffstat (limited to 'vendor/github.com/projectatomic/buildah/new.go')
-rw-r--r-- | vendor/github.com/projectatomic/buildah/new.go | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/vendor/github.com/projectatomic/buildah/new.go b/vendor/github.com/projectatomic/buildah/new.go index edc1b898e..d6aa21f8e 100644 --- a/vendor/github.com/projectatomic/buildah/new.go +++ b/vendor/github.com/projectatomic/buildah/new.go @@ -6,6 +6,7 @@ import ( "os" "strings" + "github.com/containers/image/pkg/sysregistries" is "github.com/containers/image/storage" "github.com/containers/image/transports" "github.com/containers/image/transports/alltransports" @@ -149,37 +150,25 @@ func newContainerIDMappingOptions(idmapOptions *IDMappingOptions) storage.IDMapp } return options } -func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions) (*Builder, error) { + +func resolveImage(ctx context.Context, systemContext *types.SystemContext, store storage.Store, options BuilderOptions) (types.ImageReference, *storage.Image, error) { var ref types.ImageReference var img *storage.Image - var err error - var manifest []byte - var config []byte - - if options.FromImage == BaseImageFakeName { - options.FromImage = "" - } - if options.Transport == "" { - options.Transport = DefaultTransport - } - - systemContext := getSystemContext(options.SystemContext, options.SignaturePolicyPath) - for _, image := range util.ResolveName(options.FromImage, options.Registry, systemContext, store) { + var err error if len(image) >= minimumTruncatedIDLength { if img, err = store.Image(image); err == nil && img != nil && strings.HasPrefix(img.ID, image) { if ref, err = is.Transport.ParseStoreReference(store, img.ID); err != nil { - return nil, errors.Wrapf(err, "error parsing reference to image %q", img.ID) + return nil, nil, errors.Wrapf(err, "error parsing reference to image %q", img.ID) } break } } if options.PullPolicy == PullAlways { - pulledImg, pulledReference, err2 := pullAndFindImage(ctx, store, image, options, systemContext) - if err2 != nil { - logrus.Debugf("error pulling and reading image %q: %v", image, err2) - err = err2 + pulledImg, pulledReference, err := pullAndFindImage(ctx, store, image, options, systemContext) + if err != nil { + logrus.Debugf("error pulling and reading image %q: %v", image, err) continue } ref = pulledReference @@ -187,37 +176,35 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions break } - srcRef, err2 := alltransports.ParseImageName(image) - if err2 != nil { + srcRef, err := alltransports.ParseImageName(image) + if err != nil { if options.Transport == "" { - logrus.Debugf("error parsing image name %q: %v", image, err2) - err = err2 + logrus.Debugf("error parsing image name %q: %v", image, err) continue } transport := options.Transport if transport != DefaultTransport { transport = transport + ":" } - srcRef2, err3 := alltransports.ParseImageName(transport + image) - if err3 != nil { - logrus.Debugf("error parsing image name %q: %v", image, err2) - err = err3 + srcRef2, err := alltransports.ParseImageName(transport + image) + if err != nil { + logrus.Debugf("error parsing image name %q: %v", image, err) continue } srcRef = srcRef2 } - destImage, err2 := localImageNameForReference(ctx, store, srcRef, options.FromImage) - if err2 != nil { - return nil, errors.Wrapf(err2, "error computing local image name for %q", transports.ImageName(srcRef)) + destImage, err := localImageNameForReference(ctx, store, srcRef, options.FromImage) + if err != nil { + return nil, nil, errors.Wrapf(err, "error computing local image name for %q", transports.ImageName(srcRef)) } if destImage == "" { - return nil, errors.Errorf("error computing local image name for %q", transports.ImageName(srcRef)) + return nil, nil, errors.Errorf("error computing local image name for %q", transports.ImageName(srcRef)) } ref, err = is.Transport.ParseStoreReference(store, destImage) if err != nil { - return nil, errors.Wrapf(err, "error parsing reference to image %q", destImage) + return nil, nil, errors.Wrapf(err, "error parsing reference to image %q", destImage) } img, err = is.Transport.GetStoreImage(store, ref) if err != nil { @@ -225,10 +212,9 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions logrus.Debugf("no such image %q: %v", transports.ImageName(ref), err) continue } - pulledImg, pulledReference, err2 := pullAndFindImage(ctx, store, image, options, systemContext) - if err2 != nil { - logrus.Debugf("error pulling and reading image %q: %v", image, err2) - err = err2 + pulledImg, pulledReference, err := pullAndFindImage(ctx, store, image, options, systemContext) + if err != nil { + logrus.Debugf("error pulling and reading image %q: %v", image, err) continue } ref = pulledReference @@ -236,12 +222,36 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions } break } + return ref, img, nil +} - if options.FromImage != "" && (ref == nil || img == nil) { - // If options.FromImage is set but we ended up - // with nil in ref or in img then there was an error that - // we should return. - return nil, util.GetFailureCause(err, errors.Wrapf(storage.ErrImageUnknown, "no such image %q in registry", options.FromImage)) +func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions) (*Builder, error) { + var ref types.ImageReference + var img *storage.Image + var err error + var manifest []byte + var config []byte + + if options.FromImage == BaseImageFakeName { + options.FromImage = "" + } + if options.Transport == "" { + options.Transport = DefaultTransport + } + + systemContext := getSystemContext(options.SystemContext, options.SignaturePolicyPath) + + if options.FromImage != "scratch" { + ref, img, err = resolveImage(ctx, systemContext, store, options) + if err != nil { + return nil, err + } + if options.FromImage != "" && (ref == nil || img == nil) { + // If options.FromImage is set but we ended up + // with nil in ref or in img then there was an error that + // we should return. + return nil, errors.Wrapf(storage.ErrImageUnknown, "image %q not found in %s registries", options.FromImage, sysregistries.RegistriesConfPath(systemContext)) + } } image := options.FromImage imageID := "" |