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 | |
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
-rw-r--r-- | vendor.conf | 2 | ||||
-rw-r--r-- | vendor/github.com/projectatomic/buildah/new.go | 92 | ||||
-rw-r--r-- | vendor/github.com/projectatomic/buildah/run.go | 2 |
3 files changed, 53 insertions, 43 deletions
diff --git a/vendor.conf b/vendor.conf index c69357d56..695499324 100644 --- a/vendor.conf +++ b/vendor.conf @@ -88,7 +88,7 @@ k8s.io/kube-openapi 275e2ce91dec4c05a4094a7b1daee5560b555ac9 https://github.com/ k8s.io/utils 258e2a2fa64568210fbd6267cf1d8fd87c3cb86e https://github.com/kubernetes/utils github.com/mrunalp/fileutils master github.com/varlink/go master -github.com/projectatomic/buildah 01a443f7382025264e27ec95ea203ab9314677a2 +github.com/projectatomic/buildah f90b6c0fff687c3f1453475ef4f4b1fd5727fd36 github.com/Nvveen/Gotty master github.com/fsouza/go-dockerclient master github.com/openshift/imagebuilder master 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 := "" diff --git a/vendor/github.com/projectatomic/buildah/run.go b/vendor/github.com/projectatomic/buildah/run.go index 6c85d735b..51dd5107c 100644 --- a/vendor/github.com/projectatomic/buildah/run.go +++ b/vendor/github.com/projectatomic/buildah/run.go @@ -705,7 +705,7 @@ func setupNamespaces(g *generate.Generator, namespaceOptions NamespaceOptions, i // Run runs the specified command in the container's root filesystem. func (b *Builder) Run(command []string, options RunOptions) error { var user specs.User - p, err := ioutil.TempDir(os.TempDir(), Package) + p, err := ioutil.TempDir("", Package) if err != nil { return err } |