Skip to content

Commit eb92585

Browse files
authored
init defaults to single argo cd (#27)
1 parent 7cda189 commit eb92585

3 files changed

Lines changed: 64 additions & 10 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Patternizer
22

3-
![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square)
3+
![Version: 1.2.0](https://img.shields.io/badge/Version-1.2.0-informational?style=flat-square)
44
[![Quay Repository](https://img.shields.io/badge/Quay.io-patternizer-blue?logo=quay)](https://quay.io/repository/validatedpatterns/patternizer)
55
[![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)
66

‎src/cmd/init_test.go‎

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ main:
1717
clusterGroupName: test
1818
`
1919

20+
const customGlobalValuesWithSingleArgoCDFalse = `
21+
global:
22+
pattern: test-pattern
23+
singleArgoCD: false
24+
main:
25+
clusterGroupName: test
26+
`
27+
2028
const customClusterGroupValues = `
2129
clusterGroup:
2230
name: test
@@ -65,7 +73,8 @@ var _ = Describe("patternizer init", func() {
6573
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
6674
expectedGlobalValues := types.ValuesGlobal{
6775
Global: types.Global{
68-
Pattern: filepath.Base(tempDir),
76+
Pattern: filepath.Base(tempDir),
77+
SingleArgoCD: true,
6978
SecretLoader: types.SecretLoader{
7079
Disabled: true,
7180
},
@@ -117,7 +126,8 @@ var _ = Describe("patternizer init", func() {
117126
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
118127
expectedGlobalValues := types.ValuesGlobal{
119128
Global: types.Global{
120-
Pattern: filepath.Base(tempDir),
129+
Pattern: filepath.Base(tempDir),
130+
SingleArgoCD: true,
121131
SecretLoader: types.SecretLoader{
122132
Disabled: true,
123133
},
@@ -180,7 +190,8 @@ var _ = Describe("patternizer init", func() {
180190
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
181191
expectedGlobalValues := types.ValuesGlobal{
182192
Global: types.Global{
183-
Pattern: "test-pattern",
193+
Pattern: "test-pattern",
194+
SingleArgoCD: true,
184195
SecretLoader: types.SecretLoader{
185196
Disabled: true,
186197
},
@@ -232,7 +243,8 @@ var _ = Describe("patternizer init", func() {
232243
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
233244
expectedGlobalValues := types.ValuesGlobal{
234245
Global: types.Global{
235-
Pattern: "test-pattern",
246+
Pattern: "test-pattern",
247+
SingleArgoCD: true,
236248
SecretLoader: types.SecretLoader{
237249
Disabled: true,
238250
},
@@ -271,6 +283,41 @@ var _ = Describe("patternizer init", func() {
271283
verifyClusterGroupValues(clusterGroupValuesFile, &expectedClusterGroupValues)
272284
})
273285
})
286+
287+
Context("on a directory with singleArgoCD explicitly set to false", Ordered, func() {
288+
var tempDir string
289+
290+
BeforeAll(func() {
291+
tempDir = createTestDir()
292+
Expect(os.WriteFile(filepath.Join(tempDir, "values-global.yaml"), []byte(customGlobalValuesWithSingleArgoCDFalse), 0o644)).To(Succeed())
293+
_ = runCLI(tempDir, "init")
294+
})
295+
296+
AfterAll(func() {
297+
os.RemoveAll(tempDir)
298+
})
299+
300+
It("should respect the explicit singleArgoCD override", func() {
301+
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
302+
expectedGlobalValues := types.ValuesGlobal{
303+
Global: types.Global{
304+
Pattern: "test-pattern",
305+
SingleArgoCD: false,
306+
SecretLoader: types.SecretLoader{
307+
Disabled: true,
308+
},
309+
},
310+
Main: types.Main{
311+
ClusterGroupName: "test",
312+
MultiSourceConfig: types.MultiSourceConfig{
313+
Enabled: true,
314+
ClusterGroupChartVersion: "0.9.*",
315+
},
316+
},
317+
}
318+
verifyGlobalValues(globalValuesFile, &expectedGlobalValues)
319+
})
320+
})
274321
})
275322

276323
var _ = Describe("patternizer init --with-secrets", func() {
@@ -298,7 +345,8 @@ var _ = Describe("patternizer init --with-secrets", func() {
298345
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
299346
expectedGlobalValues := types.ValuesGlobal{
300347
Global: types.Global{
301-
Pattern: filepath.Base(tempDir),
348+
Pattern: filepath.Base(tempDir),
349+
SingleArgoCD: true,
302350
SecretLoader: types.SecretLoader{
303351
Disabled: false,
304352
},
@@ -383,7 +431,8 @@ var _ = Describe("patternizer init --with-secrets", func() {
383431
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
384432
expectedGlobalValues := types.ValuesGlobal{
385433
Global: types.Global{
386-
Pattern: filepath.Base(tempDir),
434+
Pattern: filepath.Base(tempDir),
435+
SingleArgoCD: true,
387436
SecretLoader: types.SecretLoader{
388437
Disabled: false,
389438
},
@@ -478,7 +527,8 @@ var _ = Describe("patternizer init --with-secrets", func() {
478527
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
479528
expectedGlobalValues := types.ValuesGlobal{
480529
Global: types.Global{
481-
Pattern: "test-pattern",
530+
Pattern: "test-pattern",
531+
SingleArgoCD: true,
482532
SecretLoader: types.SecretLoader{
483533
Disabled: false,
484534
},
@@ -560,7 +610,8 @@ var _ = Describe("patternizer init --with-secrets", func() {
560610
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
561611
expectedGlobalValues := types.ValuesGlobal{
562612
Global: types.Global{
563-
Pattern: filepath.Base(tempDir),
613+
Pattern: filepath.Base(tempDir),
614+
SingleArgoCD: true,
564615
SecretLoader: types.SecretLoader{
565616
Disabled: false,
566617
},
@@ -656,7 +707,8 @@ var _ = Describe("patternizer init --with-secrets", func() {
656707
globalValuesFile := filepath.Join(tempDir, "values-global.yaml")
657708
expectedGlobalValues := types.ValuesGlobal{
658709
Global: types.Global{
659-
Pattern: "test-pattern",
710+
Pattern: "test-pattern",
711+
SingleArgoCD: true,
660712
SecretLoader: types.SecretLoader{
661713
Disabled: false,
662714
},

‎src/internal/types/global.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type SecretLoader struct {
99
// Global represents the 'global' section of the YAML file.
1010
type Global struct {
1111
Pattern string `yaml:"pattern"`
12+
SingleArgoCD bool `yaml:"singleArgoCD"`
1213
SecretLoader SecretLoader `yaml:"secretLoader"`
1314
OtherFields map[string]interface{} `yaml:",inline"`
1415
}
@@ -38,6 +39,7 @@ type ValuesGlobal struct {
3839
func NewDefaultValuesGlobal() *ValuesGlobal {
3940
return &ValuesGlobal{
4041
Global: Global{
42+
SingleArgoCD: true,
4143
SecretLoader: SecretLoader{
4244
Disabled: true,
4345
},

0 commit comments

Comments
 (0)