Skip to content

Commit

Permalink
feat: PR ID prefix for azure random names (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
FoSix authored Sep 1, 2023
1 parent 5a08f98 commit 48cd0df
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/testskeleton/testskeleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ type AzureRandomNames struct {
// Function that generates and returns a set of random Azure resource names.
// Randomization is based on UUID.
func GenerateAzureRandomNames() AzureRandomNames {
prid := os.Getenv("PRID")
if prid != "" {
prid = fmt.Sprintf("-pr%s-", prid)
}

id := uuid.New().String()
idSliced := strings.Split(id, "-")

Expand All @@ -76,7 +81,7 @@ func GenerateAzureRandomNames() AzureRandomNames {
storageId := idSliced[3:5]

names := AzureRandomNames{
NamePrefix: fmt.Sprintf("ghci%s-", prefixId),
NamePrefix: fmt.Sprintf("ghci%s%s-", prid, prefixId),
ResourceGroupName: strings.Join(gid, ""),
StorageAccountName: fmt.Sprintf("ghci%s", strings.Join(storageId, "")),
}
Expand Down

0 comments on commit 48cd0df

Please sign in to comment.