Skip to content

Commit

Permalink
feat: Add function to generate random names for AWS (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianczech authored Sep 12, 2023
1 parent 48cd0df commit 1669a2f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/testskeleton/testskeleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,33 @@ type AdditionalChangesAfterDeployment struct {
ChangedResources []ChangedResource
}

// Structure used for AWS deployments - contains randomly generated resource names.
type AwsRandomNames struct {
NamePrefix string
}

// Function that generates and returns a set of random AWS resource names.
// Randomization is based on UUID.
func GenerateAwRandomNames() AwsRandomNames {
prid := os.Getenv("PRID")
if prid != "" {
prid = fmt.Sprintf("pr%s", prid)
} else {
prid = "tt"
}

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

prefixId := idSliced[2]

names := AwsRandomNames{
NamePrefix: fmt.Sprintf("%s-%s-", prid, prefixId),
}

return names
}

// Structure used for Azure deployments - contains randomly generated resource names.
type AzureRandomNames struct {
NamePrefix string
Expand Down

0 comments on commit 1669a2f

Please sign in to comment.