Skip to content

Commit cd17b71

Browse files
committed
Stop setting remediationAction at the root policy level
This allows the policy generator to have granular control of the remediation action of configuration policies it may automatically generator on behalf of the user (i.e. Kyverno policy reporting). Signed-off-by: mprahl <[email protected]>
1 parent 10bf7bd commit cd17b71

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

docs/policygenerator-reference.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ policyDefaults:
3636
# file. If given, this placement rule will be used by all policies by default. (See
3737
# clusterSelectors to generate a new Placement instead.)
3838
placementRulePath: ""
39-
# Optional. The remediation action ("inform" or "enforce") for the policy. This defaults to
40-
# "inform".
39+
# Optional. The remediation action ("inform" or "enforce") for each configuration policy. This
40+
# defaults to "inform".
4141
remediationAction: "inform"
4242
# Optional. The severity of the policy violation. This defaults to "low".
4343
severity: "low"

internal/plugin.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,8 @@ func (p *Plugin) createPolicy(policyConf *types.PolicyConfig) error {
306306
"namespace": p.PolicyDefaults.Namespace,
307307
},
308308
"spec": map[string]interface{}{
309-
"disabled": policyConf.Disabled,
310-
"policy-templates": []map[string]map[string]interface{}{*policyTemplate},
311-
"remediationAction": policyConf.RemediationAction,
309+
"disabled": policyConf.Disabled,
310+
"policy-templates": []map[string]map[string]interface{}{*policyTemplate},
312311
},
313312
}
314313

internal/plugin_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ spec:
8080
name: my-configmap
8181
remediationAction: inform
8282
severity: low
83-
remediationAction: inform
8483
---
8584
apiVersion: policy.open-cluster-management.io/v1
8685
kind: Policy
@@ -111,7 +110,6 @@ spec:
111110
name: my-configmap
112111
remediationAction: inform
113112
severity: low
114-
remediationAction: inform
115113
---
116114
apiVersion: apps.open-cluster-management.io/v1
117115
kind: PlacementRule
@@ -206,7 +204,6 @@ spec:
206204
name: my-configmap
207205
remediationAction: inform
208206
severity: low
209-
remediationAction: inform
210207
---
211208
apiVersion: policy.open-cluster-management.io/v1
212209
kind: Policy
@@ -237,7 +234,6 @@ spec:
237234
name: my-configmap
238235
remediationAction: inform
239236
severity: low
240-
remediationAction: inform
241237
---
242238
apiVersion: apps.open-cluster-management.io/v1
243239
kind: PlacementRule
@@ -391,7 +387,6 @@ spec:
391387
name: my-configmap
392388
remediationAction: inform
393389
severity: low
394-
remediationAction: inform
395390
`
396391
expected = strings.TrimPrefix(expected, "\n")
397392
assertEqual(t, output, expected)
@@ -460,7 +455,6 @@ spec:
460455
name: my-configmap
461456
remediationAction: inform
462457
severity: low
463-
remediationAction: inform
464458
`
465459
expected = strings.TrimPrefix(expected, "\n")
466460
assertEqual(t, output, expected)

0 commit comments

Comments
 (0)