Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/gha-runner-scale-set/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ volumeMounts:
{{- end }}

{{- define "gha-runner-scale-set.dind-container" -}}
image: docker:dind
image: {{ .Values.containerMode.dindImage | default "docker:dind" }}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds new behavior (allowing users to override the DinD image). The chart has unit tests asserting the default docker:dind, but there’s no test covering the new override path. Add a unit test that sets containerMode.dindImage and asserts the rendered dind container image matches it.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added TestTemplateRenderedAutoScalingRunnerSet_EnableDinD_CustomImage — sets containerMode.dindImage to a custom image and asserts the rendered DinD container uses it.

args:
- dockerd
- --host=unix:///var/run/docker.sock
Expand Down
33 changes: 33 additions & 0 deletions charts/gha-runner-scale-set/tests/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,39 @@ func TestTemplateRenderedAutoScalingRunnerSet_EnableDinD(t *testing.T) {
assert.NotNil(t, ars.Spec.Template.Spec.Volumes[2].EmptyDir, "Volume work should be an emptyDir")
}

func TestTemplateRenderedAutoScalingRunnerSet_EnableDinD_CustomImage(t *testing.T) {
t.Parallel()

// Path to the helm chart we will test
helmChartPath, err := filepath.Abs("../../gha-runner-scale-set")
require.NoError(t, err)

releaseName := "test-runners"
namespaceName := "test-" + strings.ToLower(random.UniqueId())

options := &helm.Options{
Logger: logger.Discard,
SetValues: map[string]string{
"githubConfigUrl": "https://github.com/actions",
"githubConfigSecret.github_token": "gh_token12345",
"containerMode.type": "dind",
"containerMode.dindImage": "my-registry/docker:dind-custom",
"controllerServiceAccount.name": "arc",
"controllerServiceAccount.namespace": "arc-system",
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
}

output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/autoscalingrunnerset.yaml"})

var ars v1alpha1.AutoscalingRunnerSet
helm.UnmarshalK8SYaml(t, output, &ars)

assert.Len(t, ars.Spec.Template.Spec.InitContainers, 2, "Template.Spec should have 2 init containers")
assert.Equal(t, "dind", ars.Spec.Template.Spec.InitContainers[1].Name)
assert.Equal(t, "my-registry/docker:dind-custom", ars.Spec.Template.Spec.InitContainers[1].Image, "DinD container should use the custom image")
}

func TestTemplateRenderedAutoScalingRunnerSet_EnableKubernetesMode(t *testing.T) {
t.Parallel()

Expand Down
10 changes: 8 additions & 2 deletions charts/gha-runner-scale-set/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ githubConfigSecret:
## for dind and kubernetes mode. Template will be modified as documented under the
## template object.
##
## If any customization is required for dind or kubernetes mode, containerMode should remain
## empty, and configuration should be applied to the template.
## For simple customizations like overriding the DinD image, use the dindImage field below.
## For deeper customization of dind or kubernetes mode (e.g., adding extra env vars,
## volume mounts, or security contexts), containerMode should remain empty, and
## configuration should be applied to the template.
# containerMode:
# type: "dind" ## type can be set to "dind", "kubernetes", or "kubernetes-novolume"
# ## Optional: override the default docker:dind image used for the DinD sidecar container.
# ## This is useful for using a custom image with pre-configured daemon.json
# ## (e.g., registry mirrors, insecure registries) or other customizations.
# dindImage: "docker:dind"
# ## the following is required when containerMode.type=kubernetes
# kubernetesModeWorkVolumeClaim:
# accessModes: ["ReadWriteOnce"]
Expand Down