mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-19 03:11:17 +02:00
Fix #691 - ADD does not understand ENV variables
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user