-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of undefined fields for mustonlyhave
If a field exists in the object but wasn't defined for a mustonlyhave policy, we need to check the existing object's fields and set them accordingly, particularly to set them to null. ref: https://issues.redhat.com/browse/ACM-10877 Co-authored-by: Matt Prahl <mprahl@users.noreply.github.com> Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
129 additions
and
1 deletion.
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
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
23 changes: 23 additions & 0 deletions
23
test/resources/case2_role_handling/case2_rolebinding_create_enforce.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,23 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: policy-rolebinding-create | ||
spec: | ||
remediationAction: enforce | ||
namespaceSelector: | ||
include: ["default"] | ||
object-templates: | ||
- complianceType: mustonlyhave | ||
objectDefinition: | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: pod-reader-e2e-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: pod-reader-e2e | ||
subjects: | ||
- apiGroup: rbac.authorization.k8s.io | ||
kind: Group | ||
name: system:authenticated:oauth |
19 changes: 19 additions & 0 deletions
19
test/resources/case2_role_handling/case2_rolebinding_create_patch.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,19 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: policy-rolebinding-create | ||
spec: | ||
remediationAction: inform | ||
namespaceSelector: | ||
include: ["default"] | ||
object-templates: | ||
- complianceType: mustonlyhave | ||
objectDefinition: | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: pod-reader-e2e-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: pod-reader-e2e |