File tree Expand file tree Collapse file tree 4 files changed +130
-1
lines changed
resource_customizations/policy.open-cluster-management.io/Policy Expand file tree Collapse file tree 4 files changed +130
-1
lines changed Original file line number Diff line number Diff line change 1
1
hs = {}
2
- if obj .status == nil or obj . status . compliant == nil then
2
+ if obj .status == nil then
3
3
hs .status = " Progressing"
4
4
hs .message = " Waiting for the status to be reported"
5
5
return hs
6
6
end
7
+
8
+ -- A policy will not have a compliant field but will have a placement key set if
9
+ -- it is not being applied to any clusters
10
+ if obj .status .compliant == nil and # obj .status .placement > 0 and obj .status .status == nil then
11
+ hs .status = " Healthy"
12
+ hs .message = " No clusters match this policy"
13
+ return hs
14
+ end
15
+
16
+ if obj .status .compliant == nil then
17
+ hs .status = " Progressing"
18
+ hs .message = " Waiting for the status to be reported"
19
+ return hs
20
+ end
21
+
7
22
if obj .status .compliant == " Compliant" then
8
23
hs .status = " Healthy"
9
24
else
Original file line number Diff line number Diff line change @@ -15,3 +15,11 @@ tests:
15
15
status : Healthy
16
16
message : All templates are compliant
17
17
inputPath : testdata/healthy_replicated.yaml
18
+ - healthStatus :
19
+ status : Progressing
20
+ message : Waiting for the status to be reported
21
+ inputPath : testdata/progressing_no_status.yaml
22
+ - healthStatus :
23
+ status : Healthy
24
+ message : No clusters match this policy
25
+ inputPath : testdata/healthy_with_placement_empty_compliant.yaml
Original file line number Diff line number Diff line change
1
+ apiVersion : policy.open-cluster-management.io/v1
2
+ kind : Policy
3
+ metadata :
4
+ annotations :
5
+ argocd.argoproj.io/compare-options : IgnoreExtraneous
6
+ argocd.argoproj.io/sync-options : SkipDryRunOnMissingResource=true
7
+ labels :
8
+ argocd.argoproj.io/instance : acm
9
+ name : acm-hub-ca-policy
10
+ namespace : open-cluster-management
11
+ spec :
12
+ disabled : false
13
+ policy-templates :
14
+ - objectDefinition :
15
+ apiVersion : policy.open-cluster-management.io/v1
16
+ kind : ConfigurationPolicy
17
+ metadata :
18
+ name : acm-hub-ca-config-policy
19
+ spec :
20
+ namespaceSelector :
21
+ include :
22
+ - default
23
+ object-templates :
24
+ - complianceType : mustonlyhave
25
+ objectDefinition :
26
+ apiVersion : v1
27
+ data :
28
+ hub-kube-root-ca.crt : ' {{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt"
29
+ | base64enc hub}}'
30
+ hub-openshift-service-ca.crt : ' {{hub fromConfigMap "" "openshift-service-ca.crt"
31
+ "service-ca.crt" | base64enc hub}}'
32
+ kind : Secret
33
+ metadata :
34
+ name : hub-ca
35
+ namespace : golang-external-secrets
36
+ type : Opaque
37
+ - complianceType : mustonlyhave
38
+ objectDefinition :
39
+ apiVersion : v1
40
+ data :
41
+ hub-kube-root-ca.crt : |
42
+ {{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt" | autoindent hub}}
43
+ hub-openshift-service-ca.crt : |
44
+ {{hub fromConfigMap "" "openshift-service-ca.crt" "service-ca.crt" | autoindent hub}}
45
+ kind : ConfigMap
46
+ metadata :
47
+ name : trusted-hub-bundle
48
+ namespace : imperative
49
+ remediationAction : enforce
50
+ severity : medium
51
+ remediationAction : enforce
52
+ status :
53
+ placement :
54
+ - placementBinding : acm-hub-ca-policy-placement-binding
55
+ placementRule : acm-hub-ca-policy-placement
Original file line number Diff line number Diff line change
1
+ apiVersion : policy.open-cluster-management.io/v1
2
+ kind : Policy
3
+ metadata :
4
+ annotations :
5
+ argocd.argoproj.io/compare-options : IgnoreExtraneous
6
+ argocd.argoproj.io/sync-options : SkipDryRunOnMissingResource=true
7
+ labels :
8
+ argocd.argoproj.io/instance : acm
9
+ name : acm-hub-ca-policy
10
+ namespace : open-cluster-management
11
+ spec :
12
+ disabled : false
13
+ policy-templates :
14
+ - objectDefinition :
15
+ apiVersion : policy.open-cluster-management.io/v1
16
+ kind : ConfigurationPolicy
17
+ metadata :
18
+ name : acm-hub-ca-config-policy
19
+ spec :
20
+ namespaceSelector :
21
+ include :
22
+ - default
23
+ object-templates :
24
+ - complianceType : mustonlyhave
25
+ objectDefinition :
26
+ apiVersion : v1
27
+ data :
28
+ hub-kube-root-ca.crt : ' {{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt"
29
+ | base64enc hub}}'
30
+ hub-openshift-service-ca.crt : ' {{hub fromConfigMap "" "openshift-service-ca.crt"
31
+ "service-ca.crt" | base64enc hub}}'
32
+ kind : Secret
33
+ metadata :
34
+ name : hub-ca
35
+ namespace : golang-external-secrets
36
+ type : Opaque
37
+ - complianceType : mustonlyhave
38
+ objectDefinition :
39
+ apiVersion : v1
40
+ data :
41
+ hub-kube-root-ca.crt : |
42
+ {{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt" | autoindent hub}}
43
+ hub-openshift-service-ca.crt : |
44
+ {{hub fromConfigMap "" "openshift-service-ca.crt" "service-ca.crt" | autoindent hub}}
45
+ kind : ConfigMap
46
+ metadata :
47
+ name : trusted-hub-bundle
48
+ namespace : imperative
49
+ remediationAction : enforce
50
+ severity : medium
51
+ remediationAction : enforce
You can’t perform that action at this time.
0 commit comments