github.com/StackPointCloud/packer@v0.10.2-0.20180716202532-b28098e0f79b/builder/azure/arm/tempname.go (about)

     1  package arm
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/hashicorp/packer/builder/azure/common"
     7  )
     8  
     9  const (
    10  	TempNameAlphabet     = "0123456789bcdfghjklmnpqrstvwxyz"
    11  	TempPasswordAlphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    12  )
    13  
    14  type TempName struct {
    15  	AdminPassword       string
    16  	CertificatePassword string
    17  	ComputeName         string
    18  	DeploymentName      string
    19  	KeyVaultName        string
    20  	ResourceGroupName   string
    21  	OSDiskName          string
    22  	NicName             string
    23  	SubnetName          string
    24  	PublicIPAddressName string
    25  	VirtualNetworkName  string
    26  }
    27  
    28  func NewTempName() *TempName {
    29  	tempName := &TempName{}
    30  
    31  	suffix := common.RandomString(TempNameAlphabet, 10)
    32  	tempName.ComputeName = fmt.Sprintf("pkrvm%s", suffix)
    33  	tempName.DeploymentName = fmt.Sprintf("pkrdp%s", suffix)
    34  	tempName.KeyVaultName = fmt.Sprintf("pkrkv%s", suffix)
    35  	tempName.OSDiskName = fmt.Sprintf("pkros%s", suffix)
    36  	tempName.NicName = fmt.Sprintf("pkrni%s", suffix)
    37  	tempName.PublicIPAddressName = fmt.Sprintf("pkrip%s", suffix)
    38  	tempName.SubnetName = fmt.Sprintf("pkrsn%s", suffix)
    39  	tempName.VirtualNetworkName = fmt.Sprintf("pkrvn%s", suffix)
    40  	tempName.ResourceGroupName = fmt.Sprintf("packer-Resource-Group-%s", suffix)
    41  
    42  	tempName.AdminPassword = common.RandomString(TempPasswordAlphabet, 32)
    43  	tempName.CertificatePassword = common.RandomString(TempPasswordAlphabet, 32)
    44  
    45  	return tempName
    46  }