Skip to content

Commit b997c92

Browse files
Add description field to PolicyGenerator type to allow setting policy open-cluster-management.io/description
Signed-off-by: Brian Jarvis <[email protected]>
1 parent 98488b5 commit b997c92

23 files changed

+64
-0
lines changed

docs/policygenerator-reference.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ policyDefaults:
4949
kind: "Policy"
5050
# Optional. The APIVersion of the object. Defaults to "policy.open-cluster-management.io/v1"
5151
apiVersion: "policy.open-cluster-management.io/v1"
52+
# Optional. The description of the policy to create.
53+
description: ""
5254
# Optional. Determines whether the policy is enabled or disabled. A disabled policy will not be propagated to any
5355
# managed clusters and will show no status as a result.
5456
disabled: false
@@ -272,6 +274,8 @@ policies:
272274
# Optional. (See policyDefaults.dependencies for description.)
273275
# Cannot be specified when policyDefaults.orderPolicies is set to true.
274276
dependencies: []
277+
# Optional. (See policyDefaults.description for description.)
278+
description: ""
275279
# Optional. (See policyDefaults.disabled for description.)
276280
disabled: false
277281
# Optional. (See policyDefaults.evaluationInterval for description.)

internal/plugin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
550550
policy.Controls = p.PolicyDefaults.Controls
551551
}
552552

553+
if policy.Description == "" {
554+
policy.Description = p.PolicyDefaults.Description
555+
}
556+
553557
if policy.ComplianceType == "" {
554558
policy.ComplianceType = p.PolicyDefaults.ComplianceType
555559
}
@@ -1305,6 +1309,7 @@ func (p *Plugin) createPolicy(policyConf *types.PolicyConfig) error {
13051309
policyConf.PolicyAnnotations["policy.open-cluster-management.io/standards"] = strings.Join(
13061310
policyConf.Standards, ",",
13071311
)
1312+
policyConf.PolicyAnnotations["policy.open-cluster-management.io/description"] = policyConf.Description
13081313

13091314
spec := map[string]interface{}{
13101315
"disabled": policyConf.Disabled,

internal/plugin_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ metadata:
9292
annotations:
9393
policy.open-cluster-management.io/categories: CM Configuration Management
9494
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
95+
policy.open-cluster-management.io/description: ""
9596
policy.open-cluster-management.io/standards: NIST SP 800-53
9697
name: policy-app-config
9798
namespace: my-policies
@@ -127,6 +128,7 @@ metadata:
127128
annotations:
128129
policy.open-cluster-management.io/categories: CM Configuration Management
129130
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
131+
policy.open-cluster-management.io/description: ""
130132
policy.open-cluster-management.io/standards: NIST SP 800-53
131133
name: policy-app-config2
132134
namespace: my-policies
@@ -341,6 +343,7 @@ metadata:
341343
annotations:
342344
policy.open-cluster-management.io/categories: CM Configuration Management
343345
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
346+
policy.open-cluster-management.io/description: ""
344347
policy.open-cluster-management.io/standards: NIST SP 800-53
345348
name: policy-app-config
346349
namespace: my-policies
@@ -432,6 +435,7 @@ metadata:
432435
annotations:
433436
policy.open-cluster-management.io/categories: CM Configuration Management
434437
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
438+
policy.open-cluster-management.io/description: ""
435439
policy.open-cluster-management.io/standards: NIST SP 800-53
436440
name: policy-app-config
437441
namespace: my-policies
@@ -510,6 +514,7 @@ metadata:
510514
annotations:
511515
policy.open-cluster-management.io/categories: CM Configuration Management
512516
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
517+
policy.open-cluster-management.io/description: ""
513518
policy.open-cluster-management.io/standards: NIST SP 800-53
514519
name: policy-app-config
515520
namespace: my-policies
@@ -602,6 +607,7 @@ metadata:
602607
annotations:
603608
policy.open-cluster-management.io/categories: CM Configuration Management
604609
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
610+
policy.open-cluster-management.io/description: ""
605611
policy.open-cluster-management.io/standards: NIST SP 800-53
606612
name: policy-app-config
607613
namespace: my-policies
@@ -693,6 +699,7 @@ metadata:
693699
annotations:
694700
policy.open-cluster-management.io/categories: CM Configuration Management
695701
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
702+
policy.open-cluster-management.io/description: ""
696703
policy.open-cluster-management.io/standards: NIST SP 800-53
697704
name: policy-app-config
698705
namespace: my-policies
@@ -724,6 +731,7 @@ metadata:
724731
annotations:
725732
policy.open-cluster-management.io/categories: CM Configuration Management
726733
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
734+
policy.open-cluster-management.io/description: ""
727735
policy.open-cluster-management.io/standards: NIST SP 800-53
728736
name: policy-app-config2
729737
namespace: my-policies
@@ -887,6 +895,7 @@ metadata:
887895
annotations:
888896
policy.open-cluster-management.io/categories: CM Configuration Management
889897
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
898+
policy.open-cluster-management.io/description: ""
890899
policy.open-cluster-management.io/standards: NIST SP 800-53
891900
name: policy-app-config
892901
namespace: my-policies
@@ -980,6 +989,7 @@ metadata:
980989
annotations:
981990
policy.open-cluster-management.io/categories: CM Configuration Management
982991
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
992+
policy.open-cluster-management.io/description: ""
983993
policy.open-cluster-management.io/standards: NIST SP 800-53
984994
test-default-annotation: default
985995
name: policy-app-config
@@ -1028,6 +1038,7 @@ metadata:
10281038
annotations:
10291039
policy.open-cluster-management.io/categories: CM Configuration Management
10301040
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
1041+
policy.open-cluster-management.io/description: ""
10311042
policy.open-cluster-management.io/standards: NIST SP 800-53
10321043
name: policy-app-config
10331044
namespace: my-policies
@@ -1075,6 +1086,7 @@ metadata:
10751086
annotations:
10761087
policy.open-cluster-management.io/categories: CM Configuration Management
10771088
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
1089+
policy.open-cluster-management.io/description: ""
10781090
policy.open-cluster-management.io/standards: NIST SP 800-53
10791091
test-wave-annotation: "100"
10801092
name: policy-app-config
@@ -1143,6 +1155,7 @@ metadata:
11431155
annotations:
11441156
policy.open-cluster-management.io/categories: AC Access Control
11451157
policy.open-cluster-management.io/controls: AC-3 Access Enforcement
1158+
policy.open-cluster-management.io/description: ""
11461159
policy.open-cluster-management.io/standards: NIST SP 800-53
11471160
name: policy-limitclusteradmin
11481161
namespace: Iam-policies
@@ -1218,6 +1231,7 @@ metadata:
12181231
annotations:
12191232
policy.open-cluster-management.io/categories: CM Configuration Management
12201233
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
1234+
policy.open-cluster-management.io/description: ""
12211235
policy.open-cluster-management.io/standards: NIST SP 800-53
12221236
name: policy-gatekeeper
12231237
namespace: gatekeeper-policies
@@ -1283,6 +1297,7 @@ metadata:
12831297
annotations:
12841298
policy.open-cluster-management.io/categories: CM Configuration Management
12851299
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
1300+
policy.open-cluster-management.io/description: ""
12861301
policy.open-cluster-management.io/standards: NIST SP 800-53
12871302
name: policy-gatekeeper
12881303
namespace: gatekeeper-policies
@@ -1352,6 +1367,7 @@ metadata:
13521367
annotations:
13531368
policy.open-cluster-management.io/categories: AC Access Control
13541369
policy.open-cluster-management.io/controls: AC-3 Access Enforcement
1370+
policy.open-cluster-management.io/description: ""
13551371
policy.open-cluster-management.io/standards: NIST SP 800-53
13561372
name: policy-limitclusteradmin
13571373
namespace: Iam-policies
@@ -1425,6 +1441,7 @@ metadata:
14251441
annotations:
14261442
policy.open-cluster-management.io/categories: CM Configuration Management
14271443
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
1444+
policy.open-cluster-management.io/description: ""
14281445
policy.open-cluster-management.io/standards: NIST SP 800-53
14291446
name: policy-app-config
14301447
namespace: my-policies
@@ -2425,6 +2442,7 @@ metadata:
24252442
annotations:
24262443
policy.open-cluster-management.io/categories: CM Configuration Management
24272444
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
2445+
policy.open-cluster-management.io/description: ""
24282446
policy.open-cluster-management.io/standards: NIST SP 800-53
24292447
name: policy-app-config
24302448
namespace: my-policies
@@ -2552,6 +2570,7 @@ metadata:
25522570
annotations:
25532571
policy.open-cluster-management.io/categories: CM Configuration Management
25542572
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
2573+
policy.open-cluster-management.io/description: ""
25552574
policy.open-cluster-management.io/standards: NIST SP 800-53
25562575
name: policy-app-config
25572576
namespace: my-policies
@@ -2674,6 +2693,7 @@ metadata:
26742693
annotations:
26752694
policy.open-cluster-management.io/categories: CM Configuration Management
26762695
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
2696+
policy.open-cluster-management.io/description: ""
26772697
policy.open-cluster-management.io/standards: NIST SP 800-53
26782698
name: policy-app-config
26792699
namespace: my-policies
@@ -2776,6 +2796,7 @@ metadata:
27762796
annotations:
27772797
policy.open-cluster-management.io/categories: CM Configuration Management
27782798
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
2799+
policy.open-cluster-management.io/description: ""
27792800
policy.open-cluster-management.io/standards: NIST SP 800-53
27802801
name: policy-app-config
27812802
namespace: my-policies

internal/testdata/ordering/default-deps-propagated.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
annotations:
66
policy.open-cluster-management.io/categories: CM Configuration Management
77
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
8+
policy.open-cluster-management.io/description: ""
89
policy.open-cluster-management.io/standards: NIST SP 800-53
910
name: one
1011
namespace: my-policies
@@ -42,6 +43,7 @@ metadata:
4243
annotations:
4344
policy.open-cluster-management.io/categories: CM Configuration Management
4445
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
46+
policy.open-cluster-management.io/description: ""
4547
policy.open-cluster-management.io/standards: NIST SP 800-53
4648
name: two
4749
namespace: my-policies

internal/testdata/ordering/default-extradeps-consolidated.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
annotations:
66
policy.open-cluster-management.io/categories: CM Configuration Management
77
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
8+
policy.open-cluster-management.io/description: ""
89
policy.open-cluster-management.io/standards: NIST SP 800-53
910
name: one
1011
namespace: my-policies
@@ -50,6 +51,7 @@ metadata:
5051
annotations:
5152
policy.open-cluster-management.io/categories: CM Configuration Management
5253
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
54+
policy.open-cluster-management.io/description: ""
5355
policy.open-cluster-management.io/standards: NIST SP 800-53
5456
name: two
5557
namespace: my-policies

internal/testdata/ordering/default-extradeps-override.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
annotations:
66
policy.open-cluster-management.io/categories: CM Configuration Management
77
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
8+
policy.open-cluster-management.io/description: ""
89
policy.open-cluster-management.io/standards: NIST SP 800-53
910
name: one
1011
namespace: my-policies
@@ -65,6 +66,7 @@ metadata:
6566
annotations:
6667
policy.open-cluster-management.io/categories: CM Configuration Management
6768
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
69+
policy.open-cluster-management.io/description: ""
6870
policy.open-cluster-management.io/standards: NIST SP 800-53
6971
name: two
7072
namespace: my-policies

internal/testdata/ordering/default-extradeps-propagated.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
annotations:
66
policy.open-cluster-management.io/categories: CM Configuration Management
77
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
8+
policy.open-cluster-management.io/description: ""
89
policy.open-cluster-management.io/standards: NIST SP 800-53
910
name: one
1011
namespace: my-policies
@@ -65,6 +66,7 @@ metadata:
6566
annotations:
6667
policy.open-cluster-management.io/categories: CM Configuration Management
6768
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
69+
policy.open-cluster-management.io/description: ""
6870
policy.open-cluster-management.io/standards: NIST SP 800-53
6971
name: two
7072
namespace: my-policies

internal/testdata/ordering/dependency-details-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
annotations:
66
policy.open-cluster-management.io/categories: CM Configuration Management
77
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
8+
policy.open-cluster-management.io/description: ""
89
policy.open-cluster-management.io/standards: NIST SP 800-53
910
name: one
1011
namespace: my-policies

internal/testdata/ordering/extradeps-overrides.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
annotations:
66
policy.open-cluster-management.io/categories: CM Configuration Management
77
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
8+
policy.open-cluster-management.io/description: ""
89
policy.open-cluster-management.io/standards: NIST SP 800-53
910
name: one
1011
namespace: my-policies

internal/testdata/ordering/ignore-pending-manifest-override.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
annotations:
66
policy.open-cluster-management.io/categories: CM Configuration Management
77
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
8+
policy.open-cluster-management.io/description: ""
89
policy.open-cluster-management.io/standards: NIST SP 800-53
910
name: one
1011
namespace: my-policies
@@ -54,6 +55,7 @@ metadata:
5455
annotations:
5556
policy.open-cluster-management.io/categories: CM Configuration Management
5657
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
58+
policy.open-cluster-management.io/description: ""
5759
policy.open-cluster-management.io/standards: NIST SP 800-53
5860
name: two
5961
namespace: my-policies

0 commit comments

Comments
 (0)