From e31b00b6d27ae204e1a7e5d4bc9ccd923177e32f Mon Sep 17 00:00:00 2001 From: Drew Minnear Date: Mon, 15 Jun 2026 15:29:13 -0400 Subject: [PATCH] init defaults to single argo cd --- README.md | 2 +- src/cmd/init_test.go | 70 +++++++++++++++++++++++++++++++----- src/internal/types/global.go | 2 ++ 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f78f8d4..cde3945 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Patternizer -![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) +![Version: 1.2.0](https://img.shields.io/badge/Version-1.2.0-informational?style=flat-square) [![Quay Repository](https://img.shields.io/badge/Quay.io-patternizer-blue?logo=quay)](https://quay.io/repository/validatedpatterns/patternizer) [![CI Pipeline](https://github.com/validatedpatterns/patternizer/actions/workflows/build-push.yaml/badge.svg?branch=main)](https://github.com/validatedpatterns/patternizer/actions/workflows/build-push.yaml) diff --git a/src/cmd/init_test.go b/src/cmd/init_test.go index 1ad6137..c0bb1f9 100644 --- a/src/cmd/init_test.go +++ b/src/cmd/init_test.go @@ -17,6 +17,14 @@ main: clusterGroupName: test ` +const customGlobalValuesWithSingleArgoCDFalse = ` +global: + pattern: test-pattern + singleArgoCD: false +main: + clusterGroupName: test +` + const customClusterGroupValues = ` clusterGroup: name: test @@ -65,7 +73,8 @@ var _ = Describe("patternizer init", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: filepath.Base(tempDir), + Pattern: filepath.Base(tempDir), + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: true, }, @@ -117,7 +126,8 @@ var _ = Describe("patternizer init", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: filepath.Base(tempDir), + Pattern: filepath.Base(tempDir), + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: true, }, @@ -180,7 +190,8 @@ var _ = Describe("patternizer init", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: "test-pattern", + Pattern: "test-pattern", + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: true, }, @@ -232,7 +243,8 @@ var _ = Describe("patternizer init", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: "test-pattern", + Pattern: "test-pattern", + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: true, }, @@ -271,6 +283,41 @@ var _ = Describe("patternizer init", func() { verifyClusterGroupValues(clusterGroupValuesFile, &expectedClusterGroupValues) }) }) + + Context("on a directory with singleArgoCD explicitly set to false", Ordered, func() { + var tempDir string + + BeforeAll(func() { + tempDir = createTestDir() + Expect(os.WriteFile(filepath.Join(tempDir, "values-global.yaml"), []byte(customGlobalValuesWithSingleArgoCDFalse), 0o644)).To(Succeed()) + _ = runCLI(tempDir, "init") + }) + + AfterAll(func() { + os.RemoveAll(tempDir) + }) + + It("should respect the explicit singleArgoCD override", func() { + globalValuesFile := filepath.Join(tempDir, "values-global.yaml") + expectedGlobalValues := types.ValuesGlobal{ + Global: types.Global{ + Pattern: "test-pattern", + SingleArgoCD: false, + SecretLoader: types.SecretLoader{ + Disabled: true, + }, + }, + Main: types.Main{ + ClusterGroupName: "test", + MultiSourceConfig: types.MultiSourceConfig{ + Enabled: true, + ClusterGroupChartVersion: "0.9.*", + }, + }, + } + verifyGlobalValues(globalValuesFile, &expectedGlobalValues) + }) + }) }) var _ = Describe("patternizer init --with-secrets", func() { @@ -298,7 +345,8 @@ var _ = Describe("patternizer init --with-secrets", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: filepath.Base(tempDir), + Pattern: filepath.Base(tempDir), + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: false, }, @@ -383,7 +431,8 @@ var _ = Describe("patternizer init --with-secrets", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: filepath.Base(tempDir), + Pattern: filepath.Base(tempDir), + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: false, }, @@ -478,7 +527,8 @@ var _ = Describe("patternizer init --with-secrets", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: "test-pattern", + Pattern: "test-pattern", + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: false, }, @@ -560,7 +610,8 @@ var _ = Describe("patternizer init --with-secrets", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: filepath.Base(tempDir), + Pattern: filepath.Base(tempDir), + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: false, }, @@ -656,7 +707,8 @@ var _ = Describe("patternizer init --with-secrets", func() { globalValuesFile := filepath.Join(tempDir, "values-global.yaml") expectedGlobalValues := types.ValuesGlobal{ Global: types.Global{ - Pattern: "test-pattern", + Pattern: "test-pattern", + SingleArgoCD: true, SecretLoader: types.SecretLoader{ Disabled: false, }, diff --git a/src/internal/types/global.go b/src/internal/types/global.go index 7d5f076..ab5109e 100644 --- a/src/internal/types/global.go +++ b/src/internal/types/global.go @@ -9,6 +9,7 @@ type SecretLoader struct { // Global represents the 'global' section of the YAML file. type Global struct { Pattern string `yaml:"pattern"` + SingleArgoCD bool `yaml:"singleArgoCD"` SecretLoader SecretLoader `yaml:"secretLoader"` OtherFields map[string]interface{} `yaml:",inline"` } @@ -38,6 +39,7 @@ type ValuesGlobal struct { func NewDefaultValuesGlobal() *ValuesGlobal { return &ValuesGlobal{ Global: Global{ + SingleArgoCD: true, SecretLoader: SecretLoader{ Disabled: true, },