1+ suite : cluster ID configuration tests
2+ templates :
3+ - agent.yaml
4+ - controller.yaml
5+ - secret.yaml
6+ values :
7+ - values.yaml
8+ tests :
9+ - it : should use direct clusterID value when provided
10+ asserts :
11+ - contains :
12+ path : spec.template.spec.containers[0].env
13+ content :
14+ name : CLUSTER_ID
15+ value : " test-cluster-id"
16+ template : agent.yaml
17+ documentIndex : 0
18+ - contains :
19+ path : spec.template.spec.containers[0].env
20+ content :
21+ name : CLUSTER_ID
22+ value : " test-cluster-id"
23+ template : controller.yaml
24+ documentIndex : 0
25+
26+ - it : should use clusterIdConfigMapKeyRef when provided
27+ set :
28+ castai.clusterID : " "
29+ castai.clusterIdConfigMapKeyRef :
30+ name : " cluster-config"
31+ key : " CLUSTER_ID"
32+ asserts :
33+ - contains :
34+ path : spec.template.spec.containers[0].env
35+ content :
36+ name : CLUSTER_ID
37+ valueFrom :
38+ configMapKeyRef :
39+ name : " cluster-config"
40+ key : " CLUSTER_ID"
41+ template : agent.yaml
42+ documentIndex : 0
43+ - contains :
44+ path : spec.template.spec.containers[0].env
45+ content :
46+ name : CLUSTER_ID
47+ valueFrom :
48+ configMapKeyRef :
49+ name : " cluster-config"
50+ key : " CLUSTER_ID"
51+ template : controller.yaml
52+ documentIndex : 0
53+
54+ - it : should use clusterIdSecretKeyRef when provided
55+ set :
56+ castai.clusterID : " "
57+ castai.clusterIdSecretKeyRef :
58+ name : " cluster-secret"
59+ key : " CLUSTER_ID"
60+ asserts :
61+ - contains :
62+ path : spec.template.spec.containers[0].env
63+ content :
64+ name : CLUSTER_ID
65+ valueFrom :
66+ secretKeyRef :
67+ name : " cluster-secret"
68+ key : " CLUSTER_ID"
69+ template : agent.yaml
70+ documentIndex : 0
71+ - contains :
72+ path : spec.template.spec.containers[0].env
73+ content :
74+ name : CLUSTER_ID
75+ valueFrom :
76+ secretKeyRef :
77+ name : " cluster-secret"
78+ key : " CLUSTER_ID"
79+ template : controller.yaml
80+ documentIndex : 0
81+
82+ - it : should use custom key from clusterIdConfigMapKeyRef
83+ set :
84+ castai.clusterID : " "
85+ castai.clusterIdConfigMapKeyRef :
86+ name : " my-config"
87+ key : " MY_CUSTOM_KEY"
88+ asserts :
89+ - contains :
90+ path : spec.template.spec.containers[0].env
91+ content :
92+ name : CLUSTER_ID
93+ valueFrom :
94+ configMapKeyRef :
95+ name : " my-config"
96+ key : " MY_CUSTOM_KEY"
97+ template : agent.yaml
98+ documentIndex : 0
99+
100+ - it : should fail when both clusterID and clusterIdSecretKeyRef are set
101+ set :
102+ castai.clusterIdSecretKeyRef :
103+ name : " cluster-secret"
104+ key : " CLUSTER_ID"
105+ asserts :
106+ - failedTemplate :
107+ errorMessage : " clusterID cannot be used together with clusterIdConfigMapKeyRef or clusterIdSecretKeyRef"
108+ template : controller.yaml
109+
110+ - it : should fail when both clusterID and clusterIdConfigMapKeyRef are set
111+ set :
112+ castai.clusterIdConfigMapKeyRef :
113+ name : " cluster-config"
114+ key : " CLUSTER_ID"
115+ asserts :
116+ - failedTemplate :
117+ errorMessage : " clusterID cannot be used together with clusterIdConfigMapKeyRef or clusterIdSecretKeyRef"
118+ template : controller.yaml
119+
120+ - it : should prefer clusterIdConfigMapKeyRef over clusterIdSecretKeyRef when both are set
121+ set :
122+ castai.clusterID : " "
123+ castai.clusterIdSecretKeyRef :
124+ name : " cluster-secret"
125+ key : " SECRET_KEY"
126+ castai.clusterIdConfigMapKeyRef :
127+ name : " cluster-config"
128+ key : " CONFIG_KEY"
129+ asserts :
130+ - contains :
131+ path : spec.template.spec.containers[0].env
132+ content :
133+ name : CLUSTER_ID
134+ valueFrom :
135+ configMapKeyRef :
136+ name : " cluster-config"
137+ key : " CONFIG_KEY"
138+ template : agent.yaml
139+ documentIndex : 0
140+ - notContains :
141+ path : spec.template.spec.containers[0].env
142+ content :
143+ name : CLUSTER_ID
144+ valueFrom :
145+ secretKeyRef :
146+ name : " cluster-secret"
147+ key : " SECRET_KEY"
148+ template : agent.yaml
149+ documentIndex : 0
0 commit comments