Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
70 changes: 61 additions & 9 deletions src/cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ main:
clusterGroupName: test
`

const customGlobalValuesWithSingleArgoCDFalse = `
global:
pattern: test-pattern
singleArgoCD: false
main:
clusterGroupName: test
`

const customClusterGroupValues = `
clusterGroup:
name: test
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down
2 changes: 2 additions & 0 deletions src/internal/types/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -38,6 +39,7 @@ type ValuesGlobal struct {
func NewDefaultValuesGlobal() *ValuesGlobal {
return &ValuesGlobal{
Global: Global{
SingleArgoCD: true,
SecretLoader: SecretLoader{
Disabled: true,
},
Expand Down
Loading