Skip to content

Commit 6b64247

Browse files
authored
feat: enable configuration of the junit results sidecar image
1 parent eb73ef6 commit 6b64247

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

checks/junit.go

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/flanksource/canary-checker/api/context"
1212
dutyKubernetes "github.com/flanksource/duty/kubernetes"
13+
"github.com/spf13/pflag"
1314

1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1516

@@ -26,11 +27,38 @@ func init() {
2627
//register metrics here
2728
}
2829

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+
2958
const (
3059
volumeName = "junit-results"
3160
mountPath = "/tmp/junit-results"
3261
containerName = "junit-results"
33-
containerImage = "ubuntu"
3462
podKind = "Pod"
3563
junitCheckSelector = "canary-checker.flanksource.com/check"
3664
junitCheckLabelValue = "junit-check"
@@ -83,8 +111,9 @@ func newPod(ctx *context.Context, check v1.JunitCheck) (*corev1.Pod, error) {
83111
}
84112
pod.Spec.Containers = []corev1.Container{
85113
{
86-
Name: containerName,
87-
Image: containerImage,
114+
Name: containerName,
115+
ImagePullPolicy: corev1.PullPolicy(JunitContainerImagePullPolicy),
116+
Image: JunitContainerImageName,
88117
Args: []string{
89118
"bash",
90119
"-c",

cmd/root.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ func ServerFlags(flags *pflag.FlagSet) {
230230
os.Getenv("UPSTREAM_INSECURE_SKIP_VERIFY") == "true",
231231
"Skip TLS verification on the upstream servers certificate",
232232
)
233+
flags.StringVar(
234+
&checks.JunitContainerImageName,
235+
"junit-results-container-image-name",
236+
"ubuntu:latest",
237+
"Sets the container image name for the junit results container sidecar",
238+
)
239+
flags.Var(
240+
&checks.JunitContainerImagePullPolicy,
241+
"junit-results-container-image-pull-policy",
242+
fmt.Sprintf("Sets the junit results container sidecar pull policy. Allowed values: %v", checks.AllowedCorePullPolicyValues),
243+
)
233244

234245
duty.BindPFlags(flags, duty.SkipMigrationByDefaultMode)
235246

0 commit comments

Comments
 (0)