From 4923bf82adf0097ce04f3f8149886950ceabca11 Mon Sep 17 00:00:00 2001 From: Ryan Oaks Date: Thu, 2 Mar 2023 16:00:53 -0500 Subject: [PATCH] Fix project naming strategy for BootstrapProject to produce valid names in all envs --- .../terraform/utils/bootstrap_utils_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mmv1/third_party/terraform/utils/bootstrap_utils_test.go b/mmv1/third_party/terraform/utils/bootstrap_utils_test.go index e4d3e7b721c2..78131c92b747 100644 --- a/mmv1/third_party/terraform/utils/bootstrap_utils_test.go +++ b/mmv1/third_party/terraform/utils/bootstrap_utils_test.go @@ -418,16 +418,20 @@ func removeContainerServiceAgentRoleFromContainerEngineRobot(t *testing.T, proje } } -// BootstrapProject will create or get a project named "" -// that will persist across test runs. The reason for the naming is to isolate -// bootstrapped projects by test environment. +// BootstrapProject will create or get a project named +// "" that will persist across test runs, +// where projectIDSuffix is based off of getTestProjectFromEnv(). The reason +// for the naming is to isolate bootstrapped projects by test environment. +// Given the existing projects being used by our team, the prefix provided to +// this function can be no longer than 18 characters. func BootstrapProject(t *testing.T, projectIDPrefix, billingAccount string, services []string) *cloudresourcemanager.Project { config := BootstrapConfig(t) if config == nil { return nil } - projectID := fmt.Sprintf("%s%s", projectIDPrefix, getTestProjectFromEnv()) + projectIDSuffix = strings.Replace(getTestProjectFromEnv(), "ci-test-project-", "", 1) + projectID := projectIDPrefix + projectIDSuffix crmClient := config.NewResourceManagerClient(config.userAgent)