mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-22 10:38:44 +02:00
fix parent directory
This commit is contained in:
+2
-2
@@ -148,8 +148,8 @@ func ParentDirectories(path string) []string {
|
||||
dirs := strings.Split(path, "/")
|
||||
dirPath := constants.RootDir
|
||||
var paths []string
|
||||
for _, dir := range dirs {
|
||||
if dir == "" {
|
||||
for index, dir := range dirs {
|
||||
if dir == "" || index == (len(dirs)-1) {
|
||||
continue
|
||||
}
|
||||
dirPath = filepath.Join(dirPath, dir)
|
||||
|
||||
@@ -144,15 +144,12 @@ func Test_ParentDirectories(t *testing.T) {
|
||||
expected: []string{
|
||||
"/path",
|
||||
"/path/to",
|
||||
"/path/to/dir",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "current directory",
|
||||
path: ".",
|
||||
expected: []string{
|
||||
"/",
|
||||
},
|
||||
name: "current directory",
|
||||
path: ".",
|
||||
expected: nil,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user