Resolve env replacement for FROM command

This commit is contained in:
Priya Wadhwa 2018-06-04 11:51:33 -07:00
parent a641ae0b10
commit 44d7266058
No known key found for this signature in database
GPG Key ID: 0D0DAFD8F7AA73AE
3 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,5 @@
FROM scratch ARG image
FROM ${image}
# First, make sure simple arg replacement works # First, make sure simple arg replacement works
ARG file ARG file
COPY $file /foo COPY $file /foo

View File

@ -98,6 +98,7 @@ func TestRun(t *testing.T) {
"Dockerfile_test_add": {"file=context/foo"}, "Dockerfile_test_add": {"file=context/foo"},
"Dockerfile_test_onbuild": {"file=/tmp/onbuild"}, "Dockerfile_test_onbuild": {"file=/tmp/onbuild"},
"Dockerfile_test_scratch": { "Dockerfile_test_scratch": {
"image=scratch",
"hello=hello-value", "hello=hello-value",
"file=context/foo", "file=context/foo",
"file3=context/b*", "file3=context/b*",

View File

@ -63,7 +63,10 @@ func DoBuild(dockerfilePath, srcContext, snapshotMode string, args []string) (na
return nil, nil, err return nil, nil, err
} }
for index, stage := range stages { for index, stage := range stages {
baseImage := stage.BaseName baseImage, err := util.ResolveEnvironmentReplacement(stage.BaseName, args, false)
if err != nil {
return nil, nil, err
}
finalStage := index == len(stages)-1 finalStage := index == len(stages)-1
// Unpack file system to root // Unpack file system to root
logrus.Infof("Unpacking filesystem of %s...", baseImage) logrus.Infof("Unpacking filesystem of %s...", baseImage)