summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authornoah <noah@hackedu.io>2021-12-17 09:07:06 +1300
committerGitHub <noreply@github.com>2021-12-16 21:07:06 +0100
commitf201160bd30bc92912874df475873a2ff2e02fc1 (patch)
tree1c0fee2ec84ec8a8ed24fb81462771834c47809c /pkg
parentf1ebca5e02bf1973d80f2aa98cc953e70a3269fe (diff)
fix: assume kustomize application type if write back target is configured (#309)
Diffstat (limited to 'pkg')
-rw-r--r--pkg/argocd/argocd.go9
-rw-r--r--pkg/argocd/argocd_test.go21
2 files changed, 28 insertions, 2 deletions
diff --git a/pkg/argocd/argocd.go b/pkg/argocd/argocd.go
index 4183c0c..ba988f9 100644
--- a/pkg/argocd/argocd.go
+++ b/pkg/argocd/argocd.go
@@ -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
diff --git a/pkg/argocd/argocd_test.go b/pkg/argocd/argocd_test.go
index 07fdde7..4fc61bf 100644
--- a/pkg/argocd/argocd_test.go
+++ b/pkg/argocd/argocd_test.go
@@ -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) {