Fix #691 - ADD does not understand ENV variables

This commit is contained in:
Monard Vong
2019-09-15 23:08:44 +02:00
parent 38c05bae6d
commit 38474fad11
2 changed files with 14 additions and 4 deletions
+2 -1
View File
@@ -65,7 +65,8 @@ func ResolveEnvironmentReplacementList(values, envs []string, isFilepath bool) (
func ResolveEnvironmentReplacement(value string, envs []string, isFilepath bool) (string, error) {
shlex := shell.NewLex(parser.DefaultEscapeToken)
fp, err := shlex.ProcessWord(value, envs)
if !isFilepath {
// Check after replacement if value is a remote URL
if !isFilepath || IsSrcRemoteFileURL(fp) {
return fp, err
}
if err != nil {
+12 -3
View File
@@ -97,6 +97,14 @@ var testEnvReplacement = []struct {
},
expectedPath: "8080/udp",
},
{
path: "$url",
envs: []string{
"url=http://example.com",
},
isFilepath: true,
expectedPath: "http://example.com",
},
}
func Test_EnvReplacement(t *testing.T) {
@@ -472,15 +480,16 @@ func TestResolveEnvironmentReplacementList(t *testing.T) {
name: "url",
args: args{
values: []string{
"https://google.com/$foo", "$bar",
"https://google.com/$foo", "$bar", "$url",
},
envs: []string{
"foo=baz",
"bar=bat",
"url=https://google.com",
},
},
want: []string{"https://google.com/baz", "bat"},
},
want: []string{"https://google.com/baz", "bat", "https://google.com"},
},
{
name: "mixed",
args: args{