Commit fdf539d authored Dec 15, 2024 · 6 / 19 · Verified
1 parent 22fe65b commit fdf539d Copy full SHA for fdf539d
File tree 5 files changed +113
-0
lines changed
resource_customizations/addons.cluster.x-k8s.io/ClusterResourceSet
5 files changed +113
-0
lines changed Original file line number Diff line number Diff line change
1
+ function getStatus (obj )
2
+ local hs = {}
3
+ hs .status = " Progressing"
4
+ hs .message = " Initializing cluster resource set"
5
+
6
+ if obj .status ~= nil then
7
+ if obj .status .conditions ~= nil then
8
+ for i , condition in ipairs (obj .status .conditions ) do
9
+
10
+ -- Ready
11
+ if condition .type == " ResourcesApplied" and condition .status == " True" then
12
+ hs .status = " Healthy"
13
+ hs .message = " cluster resource set is applied"
14
+ return hs
15
+ end
16
+
17
+ -- Resources Applied
18
+ if condition .type == " ResourcesApplied" and condition .status == " False" then
19
+ hs .status = " Degraded"
20
+ hs .message = condition .message
21
+ return hs
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ return hs
28
+ end
29
+
30
+ local hs = getStatus (obj )
31
+ return hs
Original file line number Diff line number Diff line change
1
+ tests :
2
+ - healthStatus :
3
+ status : Progressing
4
+ message : ' Initializing cluster resource set'
5
+ inputPath : testdata/progressing_resourceapplied.yaml
6
+ - healthStatus :
7
+ status : Degraded
8
+ message : ' Failed to apply resources'
9
+ inputPath : testdata/degraded_resourceapplied.yaml
10
+ - healthStatus :
11
+ status : Healthy
12
+ message : ' cluster resource set is applied'
13
+ inputPath : testdata/healthy_resourceapplied.yaml
Original file line number Diff line number Diff line change
1
+ apiVersion : addons.cluster.x-k8s.io/v1beta1
2
+ kind : ClusterResourceSet
3
+ metadata :
4
+ finalizers :
5
+ - addons.cluster.x-k8s.io
6
+ generation : 1
7
+ labels :
8
+ app.argocd.io/instance : clustername
9
+ name : clustername-resource-set
10
+ namespace : capi-managed-cluster
11
+ spec :
12
+ clusterSelector :
13
+ matchLabels :
14
+ clusterName : clustername
15
+ resources :
16
+ - kind : ConfigMap
17
+ name : clustername-default-rbac
18
+ strategy : ApplyOnce
19
+ status :
20
+ conditions :
21
+ - lastTransitionTime : ' 2024-11-11T03:28:48Z'
22
+ message : " Failed to apply resources"
23
+ reason : RemoteClusterClientFailed
24
+ severity : Error
25
+ status : ' False'
26
+ type : ResourcesApplied
27
+ observedGeneration : 1
Original file line number Diff line number Diff line change
1
+ apiVersion : addons.cluster.x-k8s.io/v1beta1
2
+ kind : ClusterResourceSet
3
+ metadata :
4
+ finalizers :
5
+ - addons.cluster.x-k8s.io
6
+ generation : 2
7
+ labels :
8
+ app.argocd.io/instance : clustername
9
+ name : clustername-resource-set
10
+ namespace : capi-managed-cluster
11
+ spec :
12
+ clusterSelector :
13
+ matchLabels :
14
+ clusterName : clustername
15
+ resources :
16
+ - kind : ConfigMap
17
+ name : clustername-default-rbac
18
+ strategy : ApplyOnce
19
+ status :
20
+ conditions :
21
+ - lastTransitionTime : ' 2024-11-08T08:49:13Z'
22
+ status : ' True'
23
+ type : ResourcesApplied
24
+ observedGeneration : 2
Original file line number Diff line number Diff line change
1
+ apiVersion : addons.cluster.x-k8s.io/v1beta1
2
+ kind : ClusterResourceSet
3
+ metadata :
4
+ finalizers :
5
+ - addons.cluster.x-k8s.io
6
+ generation : 2
7
+ labels :
8
+ app.argocd.io/instance : clustername
9
+ name : clustername-resource-set
10
+ namespace : capi-managed-cluster
11
+ spec :
12
+ clusterSelector :
13
+ matchLabels :
14
+ clusterName : clustername
15
+ resources :
16
+ - kind : ConfigMap
17
+ name : clustername-default-rbac
18
+ strategy : ApplyOnce
You can’t perform that action at this time.
0 commit comments