From 4ea41bf5c1c6eb97ed74b07338df64fb305629d4 Mon Sep 17 00:00:00 2001 From: Poornima Krishnasamy Date: Wed, 20 Dec 2023 18:00:07 +0000 Subject: [PATCH] Add numerals to namespace and githubTeam input --- pkg/environment/githubTeamNameValidator.go | 2 +- pkg/environment/namespaceNameValidator.go | 2 +- pkg/environment/templateEnvironment_test.go | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/environment/githubTeamNameValidator.go b/pkg/environment/githubTeamNameValidator.go index b24c774c..869a1f07 100644 --- a/pkg/environment/githubTeamNameValidator.go +++ b/pkg/environment/githubTeamNameValidator.go @@ -4,6 +4,6 @@ type githubTeamNameValidator struct{} func (v *githubTeamNameValidator) isValid(s string) bool { r := new(regexValidator) - r.regex = `^[a-z\-]+$` + r.regex = `^[a-z0-9\-]+$` return r.isValid(s) } diff --git a/pkg/environment/namespaceNameValidator.go b/pkg/environment/namespaceNameValidator.go index 74ed8366..0365378d 100644 --- a/pkg/environment/namespaceNameValidator.go +++ b/pkg/environment/namespaceNameValidator.go @@ -4,6 +4,6 @@ type namespaceNameValidator struct{} func (v *namespaceNameValidator) isValid(s string) bool { r := new(regexValidator) - r.regex = `^[a-z\-]+$` + r.regex = `^[a-z0-9\-]+$` return r.isValid(s) } diff --git a/pkg/environment/templateEnvironment_test.go b/pkg/environment/templateEnvironment_test.go index 3aad1c09..6751d0cd 100644 --- a/pkg/environment/templateEnvironment_test.go +++ b/pkg/environment/templateEnvironment_test.go @@ -72,14 +72,14 @@ func TestReadAnswersFile(t *testing.T) { func TestCreateNamespace(t *testing.T) { ns := Namespace{ - Namespace: "foobar", + Namespace: "foo2bar", BusinessUnit: "My Biz Unit", Environment: "envname", Application: "My App", Owner: "Some Team", InfrastructureSupport: "some-team@digital.justice.gov.uk", SourceCode: "https://github.com/ministryofjustice/somerepo", - GithubTeam: "my-github-team", + GithubTeam: "my-github-2-team", SlackChannel: "my-team-slack_channel", IsProduction: "false", } @@ -89,7 +89,7 @@ func TestCreateNamespace(t *testing.T) { t.Errorf("Unexpected error: %s", err) } - dir := namespaceBaseFolder + "/foobar/" + dir := namespaceBaseFolder + "/foo2bar/" namespaceFile := dir + "00-namespace.yaml" rbacFile := dir + "01-rbac.yaml" variablesTfFile := dir + "resources/variables.tf" @@ -112,7 +112,7 @@ func TestCreateNamespace(t *testing.T) { } stringsInFiles := map[string]string{ - namespaceFile: "name: foobar", + namespaceFile: "name: foo2bar", namespaceFile: "cloud-platform.justice.gov.uk/business-unit: \"My Biz Unit\"", namespaceFile: "cloud-platform.justice.gov.uk/environment-name: \"envname\"", namespaceFile: "cloud-platform.justice.gov.uk/application: \"My App\"", @@ -120,9 +120,9 @@ func TestCreateNamespace(t *testing.T) { namespaceFile: "cloud-platform.justice.gov.uk/source-code: \"https://github.com/ministryofjustice/somerepo\"", namespaceFile: "cloud-platform.justice.gov.uk/is-production: \"false\"", namespaceFile: "pod-security.kubernetes.io/enforce: restricted", - rbacFile: "name: \"github:my-github-team\"", + rbacFile: "name: \"github:my-github-2-team\"", variablesTfFile: "my-team-slack_channel", - variablesTfFile: "my-github-team", + variablesTfFile: "my-github-2-team", } for filename, searchString := range stringsInFiles {