Update builder/azure/arm/tempname.go
refactor the code.. thanks for the suggestion @sylviamoss Co-Authored-By: Sylvia Moss <sylviamoss.m@gmail.com>
This commit is contained in:
parent
9209826bfe
commit
fff06353b7
|
@ -26,21 +26,11 @@ type TempName struct {
|
||||||
func NewTempName(p string) *TempName {
|
func NewTempName(p string) *TempName {
|
||||||
tempName := &TempName{}
|
tempName := &TempName{}
|
||||||
|
|
||||||
if p == "" {
|
|
||||||
suffix := random.AlphaNumLower(10)
|
|
||||||
tempName.ComputeName = fmt.Sprintf("pkrvm%s", suffix)
|
|
||||||
tempName.DeploymentName = fmt.Sprintf("pkrdp%s", suffix)
|
|
||||||
tempName.KeyVaultName = fmt.Sprintf("pkrkv%s", suffix)
|
|
||||||
tempName.OSDiskName = fmt.Sprintf("pkros%s", suffix)
|
|
||||||
tempName.NicName = fmt.Sprintf("pkrni%s", suffix)
|
|
||||||
tempName.PublicIPAddressName = fmt.Sprintf("pkrip%s", suffix)
|
|
||||||
tempName.SubnetName = fmt.Sprintf("pkrsn%s", suffix)
|
|
||||||
tempName.VirtualNetworkName = fmt.Sprintf("pkrvn%s", suffix)
|
|
||||||
tempName.NsgName = fmt.Sprintf("pkrsg%s", suffix)
|
|
||||||
tempName.ResourceGroupName = fmt.Sprintf("packer-Resource-Group-%s", suffix)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
suffix := random.AlphaNumLower(5)
|
suffix := random.AlphaNumLower(5)
|
||||||
|
if p == "" {
|
||||||
|
p = "pkr"
|
||||||
|
suffix = random.AlphaNumLower(10)
|
||||||
|
}
|
||||||
tempName.ComputeName = fmt.Sprintf("%svm%s", p, suffix)
|
tempName.ComputeName = fmt.Sprintf("%svm%s", p, suffix)
|
||||||
tempName.DeploymentName = fmt.Sprintf("%sdp%s", p, suffix)
|
tempName.DeploymentName = fmt.Sprintf("%sdp%s", p, suffix)
|
||||||
tempName.KeyVaultName = fmt.Sprintf("%skv%s", p, suffix)
|
tempName.KeyVaultName = fmt.Sprintf("%skv%s", p, suffix)
|
||||||
|
@ -52,8 +42,6 @@ func NewTempName(p string) *TempName {
|
||||||
tempName.NsgName = fmt.Sprintf("%ssg%s", p, suffix)
|
tempName.NsgName = fmt.Sprintf("%ssg%s", p, suffix)
|
||||||
tempName.ResourceGroupName = fmt.Sprintf("%s-Resource-Group-%s", p, suffix)
|
tempName.ResourceGroupName = fmt.Sprintf("%s-Resource-Group-%s", p, suffix)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
tempName.AdminPassword = generatePassword()
|
tempName.AdminPassword = generatePassword()
|
||||||
tempName.CertificatePassword = random.AlphaNum(32)
|
tempName.CertificatePassword = random.AlphaNum(32)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue