diff --git a/charts/.ci/ct-config.yaml b/charts/.ci/ct-config.yaml index 38351c90..28cbc0ab 100644 --- a/charts/.ci/ct-config.yaml +++ b/charts/.ci/ct-config.yaml @@ -1,4 +1,5 @@ # This file defines the config for "ct" (chart tester) used by the helm linting GitHub workflow +all: true lint-conf: charts/.ci/lint-config.yaml chart-repos: - jetstack=https://charts.jetstack.io diff --git a/charts/auto-scaling-runner-set/templates/autoscalingrunnerset.yaml b/charts/auto-scaling-runner-set/templates/autoscalingrunnerset.yaml index 7794d4b3..e29ec157 100644 --- a/charts/auto-scaling-runner-set/templates/autoscalingrunnerset.yaml +++ b/charts/auto-scaling-runner-set/templates/autoscalingrunnerset.yaml @@ -12,21 +12,21 @@ spec: runnerGroup: {{ . }} {{- end }} - {{- if and (kindIs "int64" .Values.minRunners) (kindIs "int64" .Values.maxRunners) }} + {{- if and (or (kindIs "int64" .Values.minRunners) (kindIs "float64" .Values.minRunners)) (or (kindIs "int64" .Values.maxRunners) (kindIs "float64" .Values.maxRunners)) }} {{- if gt .Values.minRunners .Values.maxRunners }} {{- fail "maxRunners has to be greater or equal to minRunners" }} {{- end }} {{- end }} - {{- if kindIs "int64" .Values.maxRunners }} - {{- if lt .Values.maxRunners 0 }} + {{- if or (kindIs "int64" .Values.maxRunners) (kindIs "float64" .Values.maxRunners) }} + {{- if lt (.Values.maxRunners | int) 0 }} {{- fail "maxRunners has to be greater or equal to 0" }} {{- end }} maxRunners: {{ .Values.maxRunners | int }} {{- end }} - {{- if kindIs "int64" .Values.minRunners }} - {{- if lt .Values.minRunners 0 }} + {{- if or (kindIs "int64" .Values.minRunners) (kindIs "float64" .Values.minRunners) }} + {{- if lt (.Values.minRunners | int) 0 }} {{- fail "minRunners has to be greater or equal to 0" }} {{- end }} minRunners: {{ .Values.minRunners | int }} diff --git a/charts/auto-scaling-runner-set/tests/template_test.go b/charts/auto-scaling-runner-set/tests/template_test.go index 51a8840a..099b24b6 100644 --- a/charts/auto-scaling-runner-set/tests/template_test.go +++ b/charts/auto-scaling-runner-set/tests/template_test.go @@ -495,6 +495,33 @@ func TestTemplateRenderedAutoScalingRunnerSet_MinMaxRunnersValidation_OnlyMax(t assert.Nil(t, ars.Spec.MinRunners, "MinRunners should be nil") } +func TestTemplateRenderedAutoScalingRunnerSet_MinMaxRunners_FromValuesFile(t *testing.T) { + t.Parallel() + + // Path to the helm chart we will test + helmChartPath, err := filepath.Abs("../../auto-scaling-runner-set") + require.NoError(t, err) + + testValuesPath, err := filepath.Abs("../tests/values.yaml") + require.NoError(t, err) + + releaseName := "test-runners" + namespaceName := "test-" + strings.ToLower(random.UniqueId()) + + options := &helm.Options{ + ValuesFiles: []string{testValuesPath}, + 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.Equal(t, 5, *ars.Spec.MinRunners, "MinRunners should be 5") + assert.Equal(t, 10, *ars.Spec.MaxRunners, "MaxRunners should be 10") +} + func TestTemplateRenderedAutoScalingRunnerSet_EnableDinD(t *testing.T) { t.Parallel() diff --git a/charts/auto-scaling-runner-set/tests/values.yaml b/charts/auto-scaling-runner-set/tests/values.yaml new file mode 100644 index 00000000..fc42555e --- /dev/null +++ b/charts/auto-scaling-runner-set/tests/values.yaml @@ -0,0 +1,5 @@ +githubConfigUrl: https://github.com/actions/actions-runner-controller +githubConfigSecret: + github_token: test +maxRunners: 10 +minRunners: 5 \ No newline at end of file