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
3 changes: 0 additions & 3 deletions dev/config/gitops-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,3 @@ tenantResources:
memory: 100Mi

centralRdsCidrBlock: "10.1.0.0/16"

declarativeConfig:
enabled: true
6 changes: 3 additions & 3 deletions fleetshard/pkg/central/reconciler/argo_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (r *argoReconciler) makeDesiredArgoCDApplication(remoteCentral private.Mana
delete(values, "additionalCAs")
}

if isArgoDeclarativeConfigReconciliationEnabled(remoteCentral) {
if r.isArgoDeclarativeConfigReconciliationEnabled(remoteCentral) {
dc, _ := values["declarativeConfig"].(map[string]interface{})
if dc == nil {
dc = map[string]interface{}{}
Expand Down Expand Up @@ -177,8 +177,8 @@ func (r *argoReconciler) getSourceRepoURL(m private.ManagedCentral) string {
return getTenantResourcesValue(m, "argoCd.sourceRepoUrl", r.argoOpts.TenantDefaultArgoCdAppSourceRepoURL)
}

func isArgoDeclarativeConfigReconciliationEnabled(m private.ManagedCentral) bool {
return getTenantResourcesValue(m, "declarativeConfig.enabled", false)
func (r *argoReconciler) isArgoDeclarativeConfigReconciliationEnabled(m private.ManagedCentral) bool {
return getTenantResourcesValue(m, "declarativeConfig.enabled", r.argoOpts.WantsAuthProvider)
}

func isForceReconcile(m private.ManagedCentral) bool {
Expand Down
44 changes: 29 additions & 15 deletions fleetshard/pkg/central/reconciler/argo_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,62 +53,76 @@ func TestGetSourceTargetRevision(t *testing.T) {
}

func TestDeclarativeConfigEnabled(t *testing.T) {
t.Run("returns false for empty ManagedCentral", func(t *testing.T) {
assert.False(t, isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{}))
rWithAuthProvider := argoReconciler{argoOpts: ArgoReconcilerOptions{WantsAuthProvider: true}}
rWithoutAuthProvider := argoReconciler{argoOpts: ArgoReconcilerOptions{WantsAuthProvider: false}}

t.Run("defaults to WantsAuthProvider for empty ManagedCentral", func(t *testing.T) {
assert.True(t, rWithAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{}))
assert.False(t, rWithoutAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{}))
})

t.Run("returns false for nil TenantResourcesValues", func(t *testing.T) {
assert.False(t, isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{
t.Run("defaults to WantsAuthProvider for nil TenantResourcesValues", func(t *testing.T) {
mc := private.ManagedCentral{
Spec: private.ManagedCentralAllOfSpec{
TenantResourcesValues: nil,
},
}))
}
assert.True(t, rWithAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
assert.False(t, rWithoutAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
})

t.Run("returns false when declarativeConfig is missing", func(t *testing.T) {
assert.False(t, isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{
t.Run("defaults to WantsAuthProvider when declarativeConfig is missing", func(t *testing.T) {
mc := private.ManagedCentral{
Spec: private.ManagedCentralAllOfSpec{
TenantResourcesValues: map[string]interface{}{
"other": "value",
},
},
}))
}
assert.True(t, rWithAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
assert.False(t, rWithoutAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
})

t.Run("returns false when explicitly disabled", func(t *testing.T) {
assert.False(t, isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{
mc := private.ManagedCentral{
Spec: private.ManagedCentralAllOfSpec{
TenantResourcesValues: map[string]interface{}{
"declarativeConfig": map[string]interface{}{
"enabled": false,
},
},
},
}))
}
assert.False(t, rWithAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
assert.False(t, rWithoutAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
})

t.Run("returns false when enabled is wrong type", func(t *testing.T) {
assert.False(t, isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{
t.Run("defaults to WantsAuthProvider when enabled is wrong type", func(t *testing.T) {
mc := private.ManagedCentral{
Spec: private.ManagedCentralAllOfSpec{
TenantResourcesValues: map[string]interface{}{
"declarativeConfig": map[string]interface{}{
"enabled": "true",
},
},
},
}))
}
assert.True(t, rWithAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
assert.False(t, rWithoutAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
})

t.Run("returns true when enabled", func(t *testing.T) {
assert.True(t, isArgoDeclarativeConfigReconciliationEnabled(private.ManagedCentral{
mc := private.ManagedCentral{
Spec: private.ManagedCentralAllOfSpec{
TenantResourcesValues: map[string]interface{}{
"declarativeConfig": map[string]interface{}{
"enabled": true,
},
},
},
}))
}
assert.True(t, rWithAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
assert.True(t, rWithoutAuthProvider.isArgoDeclarativeConfigReconciliationEnabled(mc))
})
}

Expand Down
Loading
Loading