Bug fix IsKustomizeDirectory returning parent dir

Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>
This commit is contained in:
Mehdi Moussaif
2023-11-24 23:42:17 +01:00
parent dfd13aea6f
commit 44ddbc6ae5

View File

@@ -25,9 +25,7 @@ func IsKustomizeDirectory(path string) bool {
return false
}
if lastChar := path[len(path)-1:]; lastChar != "/" {
path += "/"
}
path = cleanPathDir(path)
matches := 0
for _, kustomizationFileMatcher := range kustomizationFileMatchers {
@@ -71,9 +69,20 @@ func GetKustomizeDirectoryName(path string) string {
if isKustomizeDirectory := IsKustomizeDirectory(path); !isKustomizeDirectory {
return ""
}
path = cleanPathDir(path)
return filepath.Dir(path)
}
func cleanPathDir(path string) string {
if lastChar := path[len(path)-1:]; lastChar != "/" {
path += "/"
}
return path
}
// Get Workloads, creates the yaml files(K8s resources) using Kustomize and
// renders the workloads from the yaml files (k8s resources)
func (kd *KustomizeDirectory) GetWorkloads(kustomizeDirectoryPath string) (map[string][]workloadinterface.IMetadata, []error) {