Skip to content

Commit

Permalink
chore: Randomize repository names (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdt12 authored Mar 12, 2024
1 parent 61ec4eb commit 8a88dcf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/im_cloudbuild_workspace/cb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "google_cloudbuild_trigger" "triggers" {

project = var.project_id
location = var.trigger_location
name = "im-${random_id.resources_random_id.dec}-${local.default_prefix}-${each.key}"
name = substr("im-${each.key}-${random_id.resources_random_id.dec}-${local.default_prefix}", 0, 64)
description = "${title(each.key)} Terraform configs for ${var.im_deployment_repo_uri} ${var.im_deployment_repo_dir}"
include_build_logs = local.is_gh_repo ? "INCLUDE_BUILD_LOGS_WITH_STATUS" : null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestIMCloudBuildWorkspaceGitHub(t *testing.T) {
ctx := context.Background()

githubPAT := utils.ValFromEnv(t, "IM_GITHUB_PAT")
client := NewGitHubClient(t, githubPAT, "im-goose", "im-blueprint-test")
client := NewGitHubClient(t, githubPAT, "im-goose", fmt.Sprintf("im-blueprint-test-%s", getSetupRandomString(t)))

repo := client.GetRepository(ctx)
if repo == nil {
Expand Down Expand Up @@ -282,3 +282,9 @@ func getTerraformExample(t *testing.T) []byte {
}
return contents
}

func getSetupRandomString(t *testing.T) string {
t.Helper()
setup := tft.NewTFBlueprintTest(t)
return setup.GetTFSetupStringOutput("random_testing_string")
}
5 changes: 5 additions & 0 deletions test/setup/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ output "default_region" {
output "org_project_creators" {
value = ["serviceAccount:${google_service_account.int_test.email}"]
}

output "random_testing_string" {
description = "Access the random ID created in setup for labeling other resources."
value = random_id.suffix.hex
}

0 comments on commit 8a88dcf

Please sign in to comment.