Skip to content

Commit

Permalink
fix: assume kustomize application type if write back target is config…
Browse files Browse the repository at this point in the history
…ured
  • Loading branch information
iamnoah committed Dec 15, 2021
1 parent 4b13043 commit 1098046
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,14 @@ func IsValidApplicationType(app *v1alpha1.Application) bool {

// getApplicationType returns the type of the application
func getApplicationType(app *v1alpha1.Application) ApplicationType {
if app.Status.SourceType == v1alpha1.ApplicationSourceTypeKustomize {
sourceType := app.Status.SourceType
if st, set := app.Annotations[common.WriteBackTargetAnnotation]; set &&
strings.HasPrefix(st, common.KustomizationPrefix) {
sourceType = v1alpha1.ApplicationSourceTypeKustomize
}
if sourceType == v1alpha1.ApplicationSourceTypeKustomize {
return ApplicationTypeKustomize
} else if app.Status.SourceType == v1alpha1.ApplicationSourceTypeHelm {
} else if sourceType == v1alpha1.ApplicationSourceTypeHelm {
return ApplicationTypeHelm
} else {
return ApplicationTypeUnsupported
Expand Down
21 changes: 21 additions & 0 deletions pkg/argocd/argocd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,27 @@ func Test_GetApplicationType(t *testing.T) {
assert.Equal(t, "Unsupported", appType.String())
})

t.Run("Get application with kustomize target", func(t *testing.T) {
application := &v1alpha1.Application{
ObjectMeta: v1.ObjectMeta{
Name: "test-app",
Namespace: "argocd",
Annotations: map[string]string{
common.WriteBackTargetAnnotation: "kustomization:.",
},
},
Spec: v1alpha1.ApplicationSpec{},
Status: v1alpha1.ApplicationStatus{
SourceType: v1alpha1.ApplicationSourceTypePlugin,
Summary: v1alpha1.ApplicationSummary{
Images: []string{"nginx:1.12.2", "that/image", "quay.io/dexidp/dex:v1.23.0"},
},
},
}
appType := GetApplicationType(application)
assert.Equal(t, ApplicationTypeKustomize, appType)
})

}

func Test_FilterApplicationsForUpdate(t *testing.T) {
Expand Down

0 comments on commit 1098046

Please sign in to comment.