File tree Expand file tree Collapse file tree 4 files changed +61
-1
lines changed
resource_customizations/policy.open-cluster-management.io/Policy Expand file tree Collapse file tree 4 files changed +61
-1
lines changed Original file line number Diff line number Diff line change 11hs = {}
2+
23if obj .status == nil then
34 hs .status = " Progressing"
45 hs .message = " Waiting for the status to be reported"
78
89-- A policy will not have a compliant field but will have a placement key set if
910-- 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+ if obj .status .compliant == nil and obj .status .status == nil and obj .status .placement ~= nil and # obj . status . placement > 0 then
1112 hs .status = " Healthy"
1213 hs .message = " No clusters match this policy"
1314 return hs
@@ -24,6 +25,8 @@ if obj.status.compliant == "Compliant" then
2425else
2526 hs .status = " Degraded"
2627end
28+
29+ -- Collect NonCompliant clusters for the policy
2730noncompliants = {}
2831if obj .status .status ~= nil then
2932 -- "root" policy
@@ -50,4 +53,5 @@ elseif obj.status.details ~= nil then
5053 hs .message = " NonCompliant templates: " .. table.concat (noncompliants , " , " )
5154 end
5255end
56+
5357return hs
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ tests:
1919 status : Progressing
2020 message : Waiting for the status to be reported
2121 inputPath : testdata/progressing_no_status.yaml
22+ - healthStatus :
23+ status : Progressing
24+ message : Waiting for the status to be reported
25+ inputPath : testdata/progressing_nil_status.yaml
2226 - healthStatus :
2327 status : Healthy
2428 message : No clusters match this policy
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
Original file line number Diff line number Diff line change 4949 remediationAction : enforce
5050 severity : medium
5151 remediationAction : enforce
52+ status : {}
You can’t perform that action at this time.
0 commit comments