Skip to content

Commit 7f358d4

Browse files
author
Yu Cao
authored
Change PolicySet API version to v1beta1 (#40)
Signed-off-by: Yu Cao <[email protected]>
1 parent 6bf5be9 commit 7f358d4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

internal/plugin.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import (
1818

1919
const (
2020
configPolicyKind = "ConfigurationPolicy"
21-
policyAPIVersion = "policy.open-cluster-management.io/v1"
21+
policyAPIGroup = "policy.open-cluster-management.io"
22+
policyAPIVersion = policyAPIGroup + "/v1"
2223
policyKind = "Policy"
24+
poilcySetAPIVersion = policyAPIGroup + "/v1beta1"
2325
policySetKind = "PolicySet"
24-
placementBindingAPIVersion = "policy.open-cluster-management.io/v1"
26+
placementBindingAPIVersion = policyAPIGroup + "/v1"
2527
placementBindingKind = "PlacementBinding"
2628
placementRuleAPIVersion = "apps.open-cluster-management.io/v1"
2729
placementRuleKind = "PlacementRule"
@@ -870,7 +872,7 @@ func (p *Plugin) createPolicy(policyConf *types.PolicyConfig) error {
870872
// manifests specified in the configuration are invalid or can't be read.
871873
func (p *Plugin) createPolicySet(policySetConf *types.PolicySetConfig) error {
872874
policyset := map[string]interface{}{
873-
"apiVersion": policyAPIVersion,
875+
"apiVersion": poilcySetAPIVersion,
874876
"kind": policySetKind,
875877
"metadata": map[string]interface{}{
876878
"name": policySetConf.Name,
@@ -1142,8 +1144,7 @@ func (p *Plugin) createPlacementBinding(
11421144
subjects := make([]map[string]string, 0, len(policyConfs)+len(policySetConfs))
11431145
for _, policyConf := range policyConfs {
11441146
subject := map[string]string{
1145-
// Remove the version at the end
1146-
"apiGroup": strings.Split(policyAPIVersion, "/")[0],
1147+
"apiGroup": policyAPIGroup,
11471148
"kind": policyKind,
11481149
"name": policyConf.Name,
11491150
}
@@ -1152,8 +1153,7 @@ func (p *Plugin) createPlacementBinding(
11521153

11531154
for _, policySetConf := range policySetConfs {
11541155
subject := map[string]string{
1155-
// Remove the version at the end
1156-
"apiGroup": strings.Split(policyAPIVersion, "/")[0],
1156+
"apiGroup": policyAPIGroup,
11571157
"kind": policySetKind,
11581158
"name": policySetConf.Name,
11591159
}

internal/plugin_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ spec:
13841384
remediationAction: inform
13851385
severity: low
13861386
---
1387-
apiVersion: policy.open-cluster-management.io/v1
1387+
apiVersion: policy.open-cluster-management.io/v1beta1
13881388
kind: PolicySet
13891389
metadata:
13901390
name: policyset
@@ -1501,7 +1501,7 @@ spec:
15011501
remediationAction: inform
15021502
severity: low
15031503
---
1504-
apiVersion: policy.open-cluster-management.io/v1
1504+
apiVersion: policy.open-cluster-management.io/v1beta1
15051505
kind: PolicySet
15061506
metadata:
15071507
name: my-policyset
@@ -1635,7 +1635,7 @@ func TestCreatePolicySet(t *testing.T) {
16351635
output := p.outputBuffer.String()
16361636
expected := `
16371637
---
1638-
apiVersion: policy.open-cluster-management.io/v1
1638+
apiVersion: policy.open-cluster-management.io/v1beta1
16391639
kind: PolicySet
16401640
metadata:
16411641
name: policyset-default

0 commit comments

Comments
 (0)