diff --git a/.gitignore b/.gitignore index e69de29..1b3ac10 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +coverage.out \ No newline at end of file diff --git a/argocd.go b/argocd.go index 07fd4ef..1dba07f 100644 --- a/argocd.go +++ b/argocd.go @@ -125,7 +125,7 @@ func listArgoCDDeployments() error { fmt.Println("Found helm deployment with name: " + trackedDeployment.Metadata.Name) fmt.Println(" path: " + trackedDeployment.Spec.Source.Path) fmt.Println(" valueFiles: " + strings.Join(trackedDeployment.Spec.Source.Helm.ValueFiles, ", ")) - } else if _, err := os.Stat(trackedDeployment.Spec.Source.Path + "/kustomization.yaml"); err == nil { + } else if isKustomizeDir(trackedDeployment.Spec.Source.Path) { fmt.Println("---") fmt.Println("Found kustomize deployment with name: " + trackedDeployment.Metadata.Name) fmt.Println(" path: " + trackedDeployment.Spec.Source.Path) diff --git a/template.go b/template.go index 1f2f390..bc40e1e 100644 --- a/template.go +++ b/template.go @@ -13,7 +13,7 @@ import ( func renderTemplate(app ArgoCDApp) (string, error) { if app.Spec.Source.Helm.ReleaseName != "" { return renderHelm(app.Spec.Source) - } else if _, err := os.Stat(app.Spec.Source.Path + "/kustomization.yaml"); err == nil { + } else if isKustomizeDir(app.Spec.Source.Path) { return renderKustomize(app.Spec.Source.Path) } return app.Spec.Source.Path, nil diff --git a/utils.go b/utils.go index b8b1656..6a20cb2 100644 --- a/utils.go +++ b/utils.go @@ -26,3 +26,14 @@ func tempDir() (string, error) { } return dir, nil } + +func isKustomizeDir(dirPath string) bool { + if _, err := os.Stat(dirPath + "/kustomization.yaml"); err == nil { + return true + } + // Support legacy .yml extension + if _, err := os.Stat(dirPath + "/kustomization.yml"); err == nil { + return true + } + return false +}