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
12 changes: 6 additions & 6 deletions internal/ordering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ policies:
wantFile: "",
wantErr: "extraDependencies may not be set in policy one manifest[0] because orderManifests is set",
},
"orderManifests and consolidateManifests is false": {
"orderManifests is true in policyDefaults and consolidateManifests is unset": {
tmpDir: tmpDir,
generator: `
apiVersion: policy.open-cluster-management.io/v1
Expand All @@ -509,10 +509,10 @@ policies:
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
`,
wantFile: "",
wantErr: "policyDefaults may not specify both consolidateManifests and orderManifests",
wantFile: "testdata/ordering/three-ordered-manifests.yaml",
wantErr: "",
},
"orderManifests in policy and consolidateManifests is false": {
"orderManifests is true in policy and consolidateManifests is unset": {
tmpDir: tmpDir,
generator: `
apiVersion: policy.open-cluster-management.io/v1
Expand All @@ -529,8 +529,8 @@ policies:
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
- path: {{printf "%v/%v" .Dir "configmap.yaml"}}
`,
wantFile: "",
wantErr: "policy one may not set orderManifests when consolidateManifests is true",
wantFile: "testdata/ordering/three-ordered-manifests.yaml",
wantErr: "",
},
}

Expand Down
12 changes: 8 additions & 4 deletions internal/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
consolidatedValue, setConsolidated := getPolicyDefaultBool(unmarshaledConfig, "consolidateManifests")
if setConsolidated {
p.PolicyDefaults.ConsolidateManifests = consolidatedValue
} else if p.PolicyDefaults.OrderManifests {
p.PolicyDefaults.ConsolidateManifests = false
} else {
p.PolicyDefaults.ConsolidateManifests = true
}
Expand Down Expand Up @@ -608,9 +610,15 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
policy.InformKyvernoPolicies = p.PolicyDefaults.InformKyvernoPolicies
}

if !isPolicyFieldSet(unmarshaledConfig, i, "orderManifests") {
policy.OrderManifests = p.PolicyDefaults.OrderManifests
}

consolidatedValue, setConsolidated := getPolicyBool(unmarshaledConfig, i, "consolidateManifests")
if setConsolidated {
policy.ConsolidateManifests = consolidatedValue
} else if policy.OrderManifests {
policy.ConsolidateManifests = false
} else {
policy.ConsolidateManifests = p.PolicyDefaults.ConsolidateManifests
}
Expand Down Expand Up @@ -641,10 +649,6 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
policy.ExtraDependencies = p.PolicyDefaults.ExtraDependencies
}

if !isPolicyFieldSet(unmarshaledConfig, i, "orderManifests") {
policy.OrderManifests = p.PolicyDefaults.OrderManifests
}

applyDefaultPlacementFields(&policy.Placement, p.PolicyDefaults.Placement)

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