mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-10 11:41:27 +00:00
Chart naming validation on AutoscalingRunnerSet install (#2347)
Co-authored-by: Bassem Dghaidi <568794+Link-@users.noreply.github.com> Co-authored-by: Bassem Dghaidi <Link-@github.com>
This commit is contained in:
@@ -780,3 +780,45 @@ func TestTemplateRenderedWithProxy(t *testing.T) {
|
||||
assert.Contains(t, ars.Spec.Proxy.NoProxy, "example.com")
|
||||
assert.Contains(t, ars.Spec.Proxy.NoProxy, "example.org")
|
||||
}
|
||||
|
||||
func TestTemplateNamingConstraints(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)
|
||||
|
||||
setValues := map[string]string{
|
||||
"githubConfigUrl": "https://github.com/actions",
|
||||
"githubConfigSecret": "",
|
||||
}
|
||||
|
||||
tt := map[string]struct {
|
||||
releaseName string
|
||||
namespaceName string
|
||||
expectedError string
|
||||
}{
|
||||
"Name too long": {
|
||||
releaseName: strings.Repeat("a", 46),
|
||||
namespaceName: "test-" + strings.ToLower(random.UniqueId()),
|
||||
expectedError: "Name must have up to 45 characters",
|
||||
},
|
||||
"Namespace too long": {
|
||||
releaseName: "test-" + strings.ToLower(random.UniqueId()),
|
||||
namespaceName: strings.Repeat("a", 64),
|
||||
expectedError: "Namespace must have up to 63 characters",
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range tt {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
options := &helm.Options{
|
||||
SetValues: setValues,
|
||||
KubectlOptions: k8s.NewKubectlOptions("", "", tc.namespaceName),
|
||||
}
|
||||
_, err = helm.RenderTemplateE(t, options, helmChartPath, tc.releaseName, []string{"templates/autoscalingrunnerset.yaml"})
|
||||
require.Error(t, err)
|
||||
assert.ErrorContains(t, err, tc.expectedError)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user