summaryrefslogtreecommitdiff
path: root/vendor/github.com/openshift/imagebuilder/builder.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/openshift/imagebuilder/builder.go')
-rw-r--r--vendor/github.com/openshift/imagebuilder/builder.go31
1 files changed, 14 insertions, 17 deletions
diff --git a/vendor/github.com/openshift/imagebuilder/builder.go b/vendor/github.com/openshift/imagebuilder/builder.go
index 583c303c0..22dc548b9 100644
--- a/vendor/github.com/openshift/imagebuilder/builder.go
+++ b/vendor/github.com/openshift/imagebuilder/builder.go
@@ -332,20 +332,10 @@ func ParseFile(path string) (*parser.Node, error) {
// Step creates a new step from the current state.
func (b *Builder) Step() *Step {
- argsMap := make(map[string]string)
- for _, argsVal := range b.Arguments() {
- val := strings.SplitN(argsVal, "=", 2)
- if len(val) > 1 {
- argsMap[val[0]] = val[1]
- }
- }
-
- userArgs := makeUserArgs(b.Env, argsMap)
- dst := make([]string, len(userArgs)+len(b.RunConfig.Env))
- copy(dst, userArgs)
- dst = append(dst, b.RunConfig.Env...)
-
- return &Step{Env: dst}
+ // Include build arguments in the table of variables that we'll use in
+ // Resolve(), but override them with values from the actual
+ // environment in case there's any conflict.
+ return &Step{Env: mergeEnv(b.Arguments(), mergeEnv(b.Env, b.RunConfig.Env))}
}
// Run executes a step, transforming the current builder and
@@ -473,7 +463,7 @@ func (b *Builder) FromImage(image *docker.Image, node *parser.Node) error {
SplitChildren(node, command.From)
b.RunConfig = *image.Config
- b.Env = append(b.Env, b.RunConfig.Env...)
+ b.Env = mergeEnv(b.Env, b.RunConfig.Env)
b.RunConfig.Env = nil
// Check to see if we have a default PATH, note that windows won't
@@ -573,14 +563,21 @@ var builtinAllowedBuildArgs = map[string]bool{
}
// ParseDockerIgnore returns a list of the excludes in the .dockerignore file.
-// extracted from fsouza/go-dockerclient.
+// extracted from fsouza/go-dockerclient and modified to drop comments and
+// empty lines.
func ParseDockerignore(root string) ([]string, error) {
var excludes []string
ignore, err := ioutil.ReadFile(filepath.Join(root, ".dockerignore"))
if err != nil && !os.IsNotExist(err) {
return excludes, fmt.Errorf("error reading .dockerignore: '%s'", err)
}
- return strings.Split(string(ignore), "\n"), nil
+ for _, e := range strings.Split(string(ignore), "\n") {
+ if len(e) == 0 || e[0] == '#' {
+ continue
+ }
+ excludes = append(excludes, e)
+ }
+ return excludes, nil
}
// ExportEnv creates an export statement for a shell that contains all of the