diff --git a/internal/myks/sync.go b/internal/myks/sync.go index b01805db..869b6ff9 100644 --- a/internal/myks/sync.go +++ b/internal/myks/sync.go @@ -121,8 +121,7 @@ func (a Application) cleanupVendorDir(vendorDir, vendirConfigFile string) error for _, dir := range config["directories"].([]interface{}) { dirMap := dir.(map[string]interface{}) path := dirMap["path"].(string) - path = strings.TrimSuffix(path, string(filepath.Separator)) - dirs = append(dirs, path+string(filepath.Separator)) + dirs = append(dirs, filepath.Clean(path)+string(filepath.Separator)) } log.Debug().Strs("managed dirs", dirs).Msg("") diff --git a/internal/myks/sync_test.go b/internal/myks/sync_test.go index 7a64ab09..e6ae1be5 100644 --- a/internal/myks/sync_test.go +++ b/internal/myks/sync_test.go @@ -104,6 +104,31 @@ func Test_cleanupVendorDir(t *testing.T) { }, wantDirs: []string{"charts/httpbingo2"}, }, + { + name: "weird-paths", + vendirYaml: "directories:\n" + + " - path: charts/httpbingo\n" + + " - path: charts/httpbingo1/\n" + + " - path: charts/httpbingo2//\n" + + " - path: charts//httpbingo22//\n" + + " - path: charts/../httpbingo69\n", + createDirs: []string{ + "charts/httpbingo", + "charts/httpbingo1", + "charts/httpbingo2", + "charts/httpbingo22", + "httpbingo69", + "charts/trash", + "charts/trash1", + }, + wantDirs: []string{ + "charts/httpbingo", + "charts/httpbingo1", + "charts/httpbingo2", + "charts/httpbingo22", + "httpbingo69", + }, + }, } for _, tt := range tests {