mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-17 20:53:08 +02:00
Bugfix/trailing path separator (#1683)
* Test_EnvReplacement: env of path ends in a slash * Fix trailing path separator
This commit is contained in:
@@ -79,9 +79,10 @@ func ResolveEnvironmentReplacement(value string, envs []string, isFilepath bool)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
isDir := strings.HasSuffix(fp, pathSeparator)
|
||||
fp = filepath.Clean(fp)
|
||||
if IsDestDir(value) && !IsDestDir(fp) {
|
||||
fp = fp + "/"
|
||||
if isDir && !strings.HasSuffix(fp, pathSeparator) {
|
||||
fp = fp + pathSeparator
|
||||
}
|
||||
return fp, nil
|
||||
}
|
||||
|
||||
@@ -53,6 +53,14 @@ var testEnvReplacement = []struct {
|
||||
isFilepath: true,
|
||||
expectedPath: "/simple/path/",
|
||||
},
|
||||
{
|
||||
path: "$simple",
|
||||
envs: []string{
|
||||
"simple=/path/",
|
||||
},
|
||||
isFilepath: true,
|
||||
expectedPath: "/path/",
|
||||
},
|
||||
{
|
||||
path: "${a}/b",
|
||||
envs: []string{
|
||||
|
||||
Reference in New Issue
Block a user