1- // Copyright Contributors to the Open Cluster Management project
21package expanders
32
43import (
@@ -14,7 +13,7 @@ const (
1413)
1514
1615// CanHandle determines if the manifest is a Gatekeeper policy that can be expanded.
17- func (g GatekeeperPolicyExpander ) CanHandle (manifest map [string ]interface {} ) bool {
16+ func (g GatekeeperPolicyExpander ) CanHandle (manifest map [string ]any ) bool {
1817 // Verify the APIVersion
1918 if a , _ , _ := unstructured .NestedString (manifest , "apiVersion" ); a != gatekeeperConstraintAPIVersion {
2019 return false
@@ -45,36 +44,36 @@ func (g GatekeeperPolicyExpander) Enabled(policyConf *types.PolicyConfig) bool {
4544// for auditing purposes through Open Cluster Management. This should be run after the CanHandle
4645// method.
4746func (g GatekeeperPolicyExpander ) Expand (
48- manifest map [string ]interface {} , severity string ,
49- ) []map [string ]interface {} {
50- templates := []map [string ]interface {} {}
47+ manifest map [string ]any , severity string ,
48+ ) []map [string ]any {
49+ templates := []map [string ]any {}
5150 // These were previously validated in the CanHandle method.
5251 constraintName , _ , _ := unstructured .NestedString (manifest , "metadata" , "name" )
5352 constraintKind , _ , _ := unstructured .NestedString (manifest , "kind" )
5453
5554 auditConfigPolicyName := "inform-gatekeeper-audit-" + constraintName
56- auditConfigurationPolicy := map [string ]interface {} {
57- "objectDefinition" : map [string ]interface {} {
55+ auditConfigurationPolicy := map [string ]any {
56+ "objectDefinition" : map [string ]any {
5857 "apiVersion" : configPolicyAPIVersion ,
5958 "kind" : configPolicyKind ,
60- "metadata" : map [string ]interface {} {"name" : auditConfigPolicyName },
61- "spec" : map [string ]interface {} {
62- "namespaceSelector" : map [string ]interface {} {
59+ "metadata" : map [string ]any {"name" : auditConfigPolicyName },
60+ "spec" : map [string ]any {
61+ "namespaceSelector" : map [string ]any {
6362 "exclude" : []string {"kube-*" },
6463 "include" : []string {"*" },
6564 },
6665 "remediationAction" : "inform" ,
6766 "severity" : severity ,
68- "object-templates" : []map [string ]interface {} {
67+ "object-templates" : []map [string ]any {
6968 {
7069 "complianceType" : "musthave" ,
71- "objectDefinition" : map [string ]interface {} {
70+ "objectDefinition" : map [string ]any {
7271 "apiVersion" : gatekeeperConstraintAPIVersion ,
7372 "kind" : constraintKind ,
74- "metadata" : map [string ]interface {} {
73+ "metadata" : map [string ]any {
7574 "name" : constraintName ,
7675 },
77- "status" : map [string ]interface {} {
76+ "status" : map [string ]any {
7877 "totalViolations" : 0 ,
7978 },
8079 },
@@ -86,25 +85,25 @@ func (g GatekeeperPolicyExpander) Expand(
8685 // Further improvements here could be made by having the user specify the Gatekeeper namespace and
8786 // targeting the events for the constraint kind to just that namespace.
8887 admissionConfigPolicyName := "inform-gatekeeper-admission-" + constraintName
89- admissionConfigurationPolicy := map [string ]interface {} {
90- "objectDefinition" : map [string ]interface {} {
88+ admissionConfigurationPolicy := map [string ]any {
89+ "objectDefinition" : map [string ]any {
9190 "apiVersion" : configPolicyAPIVersion ,
9291 "kind" : configPolicyKind ,
93- "metadata" : map [string ]interface {} {"name" : admissionConfigPolicyName },
94- "spec" : map [string ]interface {} {
95- "namespaceSelector" : map [string ]interface {} {
92+ "metadata" : map [string ]any {"name" : admissionConfigPolicyName },
93+ "spec" : map [string ]any {
94+ "namespaceSelector" : map [string ]any {
9695 "exclude" : []string {"kube-*" },
9796 "include" : []string {"*" },
9897 },
9998 "remediationAction" : "inform" ,
10099 "severity" : severity ,
101- "object-templates" : []map [string ]interface {} {
100+ "object-templates" : []map [string ]any {
102101 {
103102 "complianceType" : "mustnothave" ,
104- "objectDefinition" : map [string ]interface {} {
103+ "objectDefinition" : map [string ]any {
105104 "apiVersion" : "v1" ,
106105 "kind" : "Event" ,
107- "annotations" : map [string ]interface {} {
106+ "annotations" : map [string ]any {
108107 "constraint_action" : "deny" ,
109108 "constraint_kind" : constraintKind ,
110109 "constraint_name" : constraintName ,
0 commit comments