@@ -10,6 +10,7 @@ import (
10
10
11
11
"github.com/flanksource/canary-checker/api/context"
12
12
dutyKubernetes "github.com/flanksource/duty/kubernetes"
13
+ "github.com/spf13/pflag"
13
14
14
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15
16
@@ -26,11 +27,38 @@ func init() {
26
27
//register metrics here
27
28
}
28
29
30
+ // type alias to implement pflag.Value to allow setting in root.go
31
+ type CorePullPolicy corev1.PullPolicy
32
+
33
+ var _ pflag.Value = (* CorePullPolicy )(nil )
34
+ var AllowedCorePullPolicyValues = []corev1.PullPolicy {corev1 .PullAlways , corev1 .PullIfNotPresent , corev1 .PullNever }
35
+
36
+ func (c * CorePullPolicy ) Set (s string ) error {
37
+ for _ , allowed := range AllowedCorePullPolicyValues {
38
+ if s == string (allowed ) {
39
+ * c = CorePullPolicy (s )
40
+ return nil
41
+ }
42
+ }
43
+
44
+ return fmt .Errorf ("PullPolicy '%s' not one of allowed values: %v" , s , AllowedCorePullPolicyValues )
45
+ }
46
+
47
+ func (c * CorePullPolicy ) String () string {
48
+ return string (* c )
49
+ }
50
+
51
+ func (c * CorePullPolicy ) Type () string {
52
+ return "CorePullPolicy"
53
+ }
54
+
55
+ var JunitContainerImageName string
56
+ var JunitContainerImagePullPolicy CorePullPolicy = CorePullPolicy (corev1 .PullIfNotPresent )
57
+
29
58
const (
30
59
volumeName = "junit-results"
31
60
mountPath = "/tmp/junit-results"
32
61
containerName = "junit-results"
33
- containerImage = "ubuntu"
34
62
podKind = "Pod"
35
63
junitCheckSelector = "canary-checker.flanksource.com/check"
36
64
junitCheckLabelValue = "junit-check"
@@ -83,8 +111,9 @@ func newPod(ctx *context.Context, check v1.JunitCheck) (*corev1.Pod, error) {
83
111
}
84
112
pod .Spec .Containers = []corev1.Container {
85
113
{
86
- Name : containerName ,
87
- Image : containerImage ,
114
+ Name : containerName ,
115
+ ImagePullPolicy : corev1 .PullPolicy (JunitContainerImagePullPolicy ),
116
+ Image : JunitContainerImageName ,
88
117
Args : []string {
89
118
"bash" ,
90
119
"-c" ,
0 commit comments