diff options
Diffstat (limited to 'vendor/github.com/projectatomic/buildah/config.go')
-rw-r--r-- | vendor/github.com/projectatomic/buildah/config.go | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/vendor/github.com/projectatomic/buildah/config.go b/vendor/github.com/projectatomic/buildah/config.go index 731e3b80a..2f4d8319a 100644 --- a/vendor/github.com/projectatomic/buildah/config.go +++ b/vendor/github.com/projectatomic/buildah/config.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "os" - "path/filepath" "runtime" "strings" "time" @@ -12,9 +11,11 @@ import ( "github.com/containers/image/manifest" "github.com/containers/image/transports" "github.com/containers/image/types" + "github.com/containers/storage/pkg/stringid" ociv1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/projectatomic/buildah/docker" + "github.com/sirupsen/logrus" ) // unmarshalConvertedConfig obtains the config blob of img valid for the wantedManifestMIMEType format @@ -107,8 +108,8 @@ func (b *Builder) fixupConfig() { if b.Architecture() == "" { b.SetArchitecture(runtime.GOARCH) } - if b.WorkDir() == "" { - b.SetWorkDir(string(filepath.Separator)) + if b.Format == Dockerv2ImageManifest && b.Hostname() == "" { + b.SetHostname(stringid.TruncateID(stringid.GenerateRandomID())) } } @@ -218,6 +219,9 @@ func (b *Builder) ClearOnBuild() { // Note: this setting is not present in the OCIv1 image format, so it is // discarded when writing images using OCIv1 formats. func (b *Builder) SetOnBuild(onBuild string) { + if onBuild != "" && b.Format != Dockerv2ImageManifest { + logrus.Errorf("ONBUILD is not supported for OCI Image formats, %s will be ignored. Must use `docker` format", onBuild) + } b.Docker.Config.OnBuild = append(b.Docker.Config.OnBuild, onBuild) } @@ -247,6 +251,10 @@ func (b *Builder) Shell() []string { // Note: this setting is not present in the OCIv1 image format, so it is // discarded when writing images using OCIv1 formats. func (b *Builder) SetShell(shell []string) { + if len(shell) > 0 && b.Format != Dockerv2ImageManifest { + logrus.Errorf("SHELL is not supported for OCI Image format, %s will be ignored. Must use `docker` format", shell) + } + b.Docker.Config.Shell = copyStringSlice(shell) } @@ -327,7 +335,10 @@ func (b *Builder) SetCmd(cmd []string) { // Entrypoint returns the command to be run for containers built from images // built from this container. func (b *Builder) Entrypoint() []string { - return copyStringSlice(b.OCIv1.Config.Entrypoint) + if len(b.OCIv1.Config.Entrypoint) > 0 { + return copyStringSlice(b.OCIv1.Config.Entrypoint) + } + return nil } // SetEntrypoint sets the command to be run for in containers built from images @@ -416,7 +427,10 @@ func (b *Builder) Volumes() []string { for k := range b.OCIv1.Config.Volumes { v = append(v, k) } - return v + if len(v) > 0 { + return v + } + return nil } // AddVolume adds a location to the image's list of locations which should be @@ -460,6 +474,9 @@ func (b *Builder) Hostname() string { // Note: this setting is not present in the OCIv1 image format, so it is // discarded when writing images using OCIv1 formats. func (b *Builder) SetHostname(name string) { + if name != "" && b.Format != Dockerv2ImageManifest { + logrus.Errorf("HOSTNAME is not supported for OCI Image format, hostname %s will be ignored. Must use `docker` format", name) + } b.Docker.Config.Hostname = name } @@ -474,6 +491,9 @@ func (b *Builder) Domainname() string { // Note: this setting is not present in the OCIv1 image format, so it is // discarded when writing images using OCIv1 formats. func (b *Builder) SetDomainname(name string) { + if name != "" && b.Format != Dockerv2ImageManifest { + logrus.Errorf("DOMAINNAME is not supported for OCI Image format, domainname %s will be ignored. Must use `docker` format", name) + } b.Docker.Config.Domainname = name } @@ -493,6 +513,9 @@ func (b *Builder) Comment() string { // Note: this setting is not present in the OCIv1 image format, so it is // discarded when writing images using OCIv1 formats. func (b *Builder) SetComment(comment string) { + if comment != "" && b.Format != Dockerv2ImageManifest { + logrus.Errorf("COMMENT is not supported for OCI Image format, comment %s will be ignored. Must use `docker` format", comment) + } b.Docker.Comment = comment } |