Skip to content

Commit 09880ef

Browse files
JeffeyLopenshift-merge-robot
authored andcommitted
Fix bug to set consolidateManifests=false when orderManifests=true
Simple checks added on conditionals for both default and actual values to change consolidateManifests=false Signed-off-by: Jeffrey Luo <[email protected]>
1 parent 6bd4ae3 commit 09880ef

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

internal/ordering_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ policies:
492492
wantFile: "",
493493
wantErr: "extraDependencies may not be set in policy one manifest[0] because orderManifests is set",
494494
},
495-
"orderManifests and consolidateManifests is false": {
495+
"orderManifests is true in policyDefaults and consolidateManifests is unset": {
496496
tmpDir: tmpDir,
497497
generator: `
498498
apiVersion: policy.open-cluster-management.io/v1
@@ -509,10 +509,10 @@ policies:
509509
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
510510
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
511511
`,
512-
wantFile: "",
513-
wantErr: "policyDefaults may not specify both consolidateManifests and orderManifests",
512+
wantFile: "testdata/ordering/three-ordered-manifests.yaml",
513+
wantErr: "",
514514
},
515-
"orderManifests in policy and consolidateManifests is false": {
515+
"orderManifests is true in policy and consolidateManifests is unset": {
516516
tmpDir: tmpDir,
517517
generator: `
518518
apiVersion: policy.open-cluster-management.io/v1
@@ -529,8 +529,8 @@ policies:
529529
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
530530
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
531531
`,
532-
wantFile: "",
533-
wantErr: "policy one may not set orderManifests when consolidateManifests is true",
532+
wantFile: "testdata/ordering/three-ordered-manifests.yaml",
533+
wantErr: "",
534534
},
535535
}
536536

internal/plugin.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
458458
consolidatedValue, setConsolidated := getPolicyDefaultBool(unmarshaledConfig, "consolidateManifests")
459459
if setConsolidated {
460460
p.PolicyDefaults.ConsolidateManifests = consolidatedValue
461+
} else if p.PolicyDefaults.OrderManifests {
462+
p.PolicyDefaults.ConsolidateManifests = false
461463
} else {
462464
p.PolicyDefaults.ConsolidateManifests = true
463465
}
@@ -608,9 +610,15 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
608610
policy.InformKyvernoPolicies = p.PolicyDefaults.InformKyvernoPolicies
609611
}
610612

613+
if !isPolicyFieldSet(unmarshaledConfig, i, "orderManifests") {
614+
policy.OrderManifests = p.PolicyDefaults.OrderManifests
615+
}
616+
611617
consolidatedValue, setConsolidated := getPolicyBool(unmarshaledConfig, i, "consolidateManifests")
612618
if setConsolidated {
613619
policy.ConsolidateManifests = consolidatedValue
620+
} else if policy.OrderManifests {
621+
policy.ConsolidateManifests = false
614622
} else {
615623
policy.ConsolidateManifests = p.PolicyDefaults.ConsolidateManifests
616624
}
@@ -641,10 +649,6 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
641649
policy.ExtraDependencies = p.PolicyDefaults.ExtraDependencies
642650
}
643651

644-
if !isPolicyFieldSet(unmarshaledConfig, i, "orderManifests") {
645-
policy.OrderManifests = p.PolicyDefaults.OrderManifests
646-
}
647-
648652
applyDefaultPlacementFields(&policy.Placement, p.PolicyDefaults.Placement)
649653

650654
// Only use defaults when the namespaceSelector is not set on the policy

0 commit comments

Comments
 (0)