forked from stolostron/config-policy-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix constantly updating objects with a null struct
It was tricky to find an example of this. Most optional structs I found would get populated with some default values, meaning they wouldn't be omitted by the kube api. Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
- Loading branch information
1 parent
fd913d8
commit dff741d
Showing
4 changed files
with
120 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
test/resources/case31_policy_history/event-config-policy-emptystruct.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: config-policy-event-emptystruct | ||
labels: | ||
policy.open-cluster-management.io/policy: test-policy-security | ||
ownerReferences: | ||
- apiVersion: policy.open-cluster-management.io/v1 | ||
blockOwnerDeletion: false | ||
controller: true | ||
kind: Policy | ||
name: test-policy-security-emptystruct | ||
uid: 08bae967-4262-498a-84e9-d1f0e321b41e | ||
spec: | ||
pruneObjectBehavior: DeleteAll | ||
remediationAction: enforce | ||
namespaceSelector: | ||
exclude: | ||
- kube-public | ||
include: | ||
- default | ||
- kube-system | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
action: DidTheThing | ||
apiVersion: events.k8s.io/v1 | ||
eventTime: 2023-04-27T14:37:36.721589Z | ||
kind: Event | ||
metadata: | ||
name: configpol-test-event | ||
namespace: kube-system | ||
note: Successfully did something | ||
reason: Success | ||
regarding: null | ||
related: null | ||
reportingController: ConfigPolicyTester | ||
reportingInstance: configpol-history-test | ||
type: Normal |
42 changes: 42 additions & 0 deletions
42
test/resources/case31_policy_history/event-policy-emptystruct.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: test-policy-security-emptystruct | ||
annotations: | ||
policy.open-cluster.management.io/standards: NIST-CSF | ||
policy.open-cluster.management.io/categories: PR.PT Protective Technology | ||
policy.open-cluster.management.io/controls: PR.PT-3 Least Functionality | ||
spec: | ||
remediationAction: enforce | ||
disabled: false | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: config-policy-event-emptystruct | ||
spec: | ||
remediationAction: enforce | ||
namespaceSelector: | ||
exclude: | ||
- kube-public | ||
include: | ||
- default | ||
- kube-system | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
action: DidTheThing | ||
apiVersion: events.k8s.io/v1 | ||
eventTime: 2023-04-27T14:37:36.721589Z | ||
kind: Event | ||
metadata: | ||
name: configpol-test-event | ||
namespace: kube-system | ||
note: Successfully did something | ||
reason: Success | ||
regarding: null | ||
related: null | ||
reportingController: ConfigPolicyTester | ||
reportingInstance: configpol-history-test | ||
type: Normal |