Skip to content

Commit

Permalink
Merge pull request #23 from coopnorge/allow-legacy-yml-extention
Browse files Browse the repository at this point in the history
fix: Allow legacy ".yml" extension for kustomize-file
  • Loading branch information
bendiknesbo authored Jan 29, 2024
2 parents b12c75d + 55ceff3 commit 8b4ad56
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage.out
2 changes: 1 addition & 1 deletion argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 8b4ad56

Please sign in to comment.