@@ -73,6 +73,7 @@ func Test_000260_runner_pod_test(t *testing.T) {
73
73
spec := reconciler .runnerPodSpec (helloWorldTF , "runner.tls-123" )
74
74
g .Expect (spec .ServiceAccountName ).To (Equal (serviceAccountName ))
75
75
g .Expect (spec .Containers [0 ].Image ).To (Equal (runnerPodImage ))
76
+ g .Expect (spec .Containers [0 ].ImagePullPolicy ).To (Equal (corev1 .PullIfNotPresent ))
76
77
g .Expect (spec .HostAliases [0 ].Hostnames ).To (Equal ([]string {"foo" , "bar" }))
77
78
78
79
podTemplate , err := runnerPodTemplate (helloWorldTF , "runner.tls-123" , revision )
@@ -178,6 +179,76 @@ func Test_000260_runner_pod_test_env_vars(t *testing.T) {
178
179
}()).To (BeTrue ())
179
180
}
180
181
182
+ func Test_000260_runner_pod_a_test_image_pull_policy (t * testing.T ) {
183
+ Spec ("This spec describes a runner pod creation process" )
184
+
185
+ const (
186
+ terraformName = "runner-pod-test"
187
+ sourceName = "runner-pod-test"
188
+ serviceAccountName = "helloworld-tf-runner"
189
+ runnerPodImage = "ghcr.io/weaveworks/tf-runner:test"
190
+ revision = "v2.6@sha256:c7fd0cc69b924aa5f9a6928477311737e439ca1b9e444855b0377e8a8ec65bb5"
191
+ )
192
+
193
+ var stringMap = map [string ]string {
194
+ "company.com/abc" : "xyz" ,
195
+ "company.com/xyz" : "abc" ,
196
+ "tf.weave.works/tls-secret-name" : "runner.tls-123" ,
197
+ }
198
+
199
+ g := NewWithT (t )
200
+
201
+ It ("generate a runner pod template" )
202
+ By ("passing a terraform object, the runner pod template should be accurate" )
203
+ helloWorldTF := infrav1.Terraform {
204
+ ObjectMeta : metav1.ObjectMeta {
205
+ Name : terraformName ,
206
+ Namespace : "flux-system" ,
207
+ },
208
+ Spec : infrav1.TerraformSpec {
209
+ ApprovePlan : "auto" ,
210
+ Path : "./terraform-hello-world-example" ,
211
+ SourceRef : infrav1.CrossNamespaceSourceReference {
212
+ Kind : "GitRepository" ,
213
+ Name : sourceName ,
214
+ Namespace : "flux-system" ,
215
+ },
216
+ ServiceAccountName : serviceAccountName ,
217
+ RunnerPodTemplate : infrav1.RunnerPodTemplate {
218
+ Metadata : infrav1.RunnerPodMetadata {
219
+ Labels : stringMap ,
220
+ Annotations : stringMap ,
221
+ },
222
+ Spec : infrav1.RunnerPodSpec {
223
+ Image : runnerPodImage ,
224
+ ImagePullPolicy : "Always" ,
225
+ },
226
+ },
227
+ },
228
+ }
229
+
230
+ spec := reconciler .runnerPodSpec (helloWorldTF , "runner.tls-123" )
231
+ g .Expect (spec .ServiceAccountName ).To (Equal (serviceAccountName ))
232
+ g .Expect (spec .Containers [0 ].Image ).To (Equal (runnerPodImage ))
233
+ g .Expect (spec .Containers [0 ].ImagePullPolicy ).To (Equal (corev1 .PullAlways ))
234
+
235
+ podTemplate , err := runnerPodTemplate (helloWorldTF , "runner.tls-123" , revision )
236
+ g .Expect (err ).ToNot (HaveOccurred ())
237
+ g .Expect (func () bool {
238
+ for k , v := range stringMap {
239
+ if v != podTemplate .ObjectMeta .Labels [k ] {
240
+ return false
241
+ }
242
+ }
243
+ for k , v := range stringMap {
244
+ if v != podTemplate .ObjectMeta .Annotations [k ] {
245
+ return false
246
+ }
247
+ }
248
+ return true
249
+ }()).To (BeTrue ())
250
+ }
251
+
181
252
func Test_000260_runner_pod_test_env_vars_proxy (t * testing.T ) {
182
253
Spec ("This spec describes a runner pod creation process" )
183
254
0 commit comments