Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Sync from open-cluster-management-io/policy-generator-plugin: #139 #48

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/policygenerator-reference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ policyDefaults:
kind: "Policy"
# Optional. The APIVersion of the object. Defaults to "policy.open-cluster-management.io/v1"
apiVersion: "policy.open-cluster-management.io/v1"
# Optional. The description of the policy to create.
description: ""
# Optional. Determines whether the policy is enabled or disabled. A disabled policy will not be propagated to any
# managed clusters and will show no status as a result.
disabled: false
Expand Down Expand Up @@ -272,6 +274,8 @@ policies:
# Optional. (See policyDefaults.dependencies for description.)
# Cannot be specified when policyDefaults.orderPolicies is set to true.
dependencies: []
# Optional. (See policyDefaults.description for description.)
description: ""
# Optional. (See policyDefaults.disabled for description.)
disabled: false
# Optional. (See policyDefaults.evaluationInterval for description.)
Expand Down
5 changes: 5 additions & 0 deletions internal/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ func (p *Plugin) applyDefaults(unmarshaledConfig map[string]interface{}) {
policy.Controls = p.PolicyDefaults.Controls
}

if policy.Description == "" {
policy.Description = p.PolicyDefaults.Description
}

if policy.ComplianceType == "" {
policy.ComplianceType = p.PolicyDefaults.ComplianceType
}
Expand Down Expand Up @@ -1305,6 +1309,7 @@ func (p *Plugin) createPolicy(policyConf *types.PolicyConfig) error {
policyConf.PolicyAnnotations["policy.open-cluster-management.io/standards"] = strings.Join(
policyConf.Standards, ",",
)
policyConf.PolicyAnnotations["policy.open-cluster-management.io/description"] = policyConf.Description

spec := map[string]interface{}{
"disabled": policyConf.Disabled,
Expand Down
21 changes: 21 additions & 0 deletions internal/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -127,6 +128,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config2
namespace: my-policies
Expand Down Expand Up @@ -341,6 +343,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -432,6 +435,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -510,6 +514,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -602,6 +607,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -693,6 +699,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -724,6 +731,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config2
namespace: my-policies
Expand Down Expand Up @@ -887,6 +895,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -980,6 +989,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
test-default-annotation: default
name: policy-app-config
Expand Down Expand Up @@ -1028,6 +1038,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -1075,6 +1086,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
test-wave-annotation: "100"
name: policy-app-config
Expand Down Expand Up @@ -1143,6 +1155,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: AC Access Control
policy.open-cluster-management.io/controls: AC-3 Access Enforcement
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-limitclusteradmin
namespace: Iam-policies
Expand Down Expand Up @@ -1218,6 +1231,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-gatekeeper
namespace: gatekeeper-policies
Expand Down Expand Up @@ -1283,6 +1297,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-gatekeeper
namespace: gatekeeper-policies
Expand Down Expand Up @@ -1352,6 +1367,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: AC Access Control
policy.open-cluster-management.io/controls: AC-3 Access Enforcement
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-limitclusteradmin
namespace: Iam-policies
Expand Down Expand Up @@ -1425,6 +1441,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -2425,6 +2442,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -2552,6 +2570,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -2674,6 +2693,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down Expand Up @@ -2776,6 +2796,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: policy-app-config
namespace: my-policies
Expand Down
2 changes: 2 additions & 0 deletions internal/testdata/ordering/default-deps-propagated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -42,6 +43,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -50,6 +51,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
2 changes: 2 additions & 0 deletions internal/testdata/ordering/default-extradeps-override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -65,6 +66,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
2 changes: 2 additions & 0 deletions internal/testdata/ordering/default-extradeps-propagated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -65,6 +66,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
1 change: 1 addition & 0 deletions internal/testdata/ordering/dependency-details-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down
1 change: 1 addition & 0 deletions internal/testdata/ordering/extradeps-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -54,6 +55,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -45,6 +46,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -55,6 +56,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
2 changes: 2 additions & 0 deletions internal/testdata/ordering/ignore-pending-propagation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -55,6 +56,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/standards: NIST SP 800-53
policy.open-cluster-management.io/description: ""
name: one
namespace: my-policies
spec:
Expand Down Expand Up @@ -64,6 +65,7 @@ metadata:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/standards: NIST SP 800-53
policy.open-cluster-management.io/description: ""
name: two
namespace: my-policies
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -58,6 +59,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
2 changes: 2 additions & 0 deletions internal/testdata/ordering/manifest-extradeps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: one
namespace: my-policies
Expand Down Expand Up @@ -59,6 +60,7 @@ metadata:
annotations:
policy.open-cluster-management.io/categories: CM Configuration Management
policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
policy.open-cluster-management.io/description: ""
policy.open-cluster-management.io/standards: NIST SP 800-53
name: two
namespace: my-policies
Expand Down
Loading