summaryrefslogtreecommitdiff
path: root/vendor/github.com/openshift/imagebuilder/internals.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/openshift/imagebuilder/internals.go')
-rw-r--r--vendor/github.com/openshift/imagebuilder/internals.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/vendor/github.com/openshift/imagebuilder/internals.go b/vendor/github.com/openshift/imagebuilder/internals.go
index 3c60c7983..b652dc1c7 100644
--- a/vendor/github.com/openshift/imagebuilder/internals.go
+++ b/vendor/github.com/openshift/imagebuilder/internals.go
@@ -92,3 +92,28 @@ func parseOptInterval(f *flag.Flag) (time.Duration, error) {
}
return d, nil
}
+
+// makeUserArgs - Package the variables from the Dockerfile defined by
+// the ENV aand the ARG statements into one slice so the values
+// defined by both can later be evaluated when resolving variables
+// such as ${MY_USER}. If the variable is defined by both ARG and ENV
+// don't include the definition of the ARG variable.
+func makeUserArgs(bEnv []string, bArgs map[string]string) (userArgs []string) {
+
+ userArgs = bEnv
+ envMap := make(map[string]string)
+ for _, envVal := range bEnv {
+ val := strings.Split(envVal, "=")
+ if len(val) > 1 {
+ envMap[val[0]] = val[1]
+ }
+ }
+
+ for key, value := range bArgs {
+ if _, ok := envMap[key]; ok {
+ continue
+ }
+ userArgs = append(userArgs, key+"="+value)
+ }
+ return userArgs
+}