github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/builder/azure/arm/tempname.go (about)

     1  // Copyright (c) Microsoft Corporation. All rights reserved.
     2  // Licensed under the MIT License. See the LICENSE file in builder/azure for license information.
     3  
     4  package arm
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/mitchellh/packer/builder/azure/common"
    10  )
    11  
    12  const (
    13  	TempNameAlphabet     = "0123456789bcdfghjklmnpqrstvwxyz"
    14  	TempPasswordAlphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    15  )
    16  
    17  type TempName struct {
    18  	AdminPassword     string
    19  	ComputeName       string
    20  	DeploymentName    string
    21  	ResourceGroupName string
    22  	OSDiskName        string
    23  }
    24  
    25  func NewTempName() *TempName {
    26  	tempName := &TempName{}
    27  
    28  	suffix := common.RandomString(TempNameAlphabet, 10)
    29  	tempName.ComputeName = fmt.Sprintf("pkrvm%s", suffix)
    30  	tempName.DeploymentName = fmt.Sprintf("pkrdp%s", suffix)
    31  	tempName.OSDiskName = fmt.Sprintf("pkros%s", suffix)
    32  	tempName.ResourceGroupName = fmt.Sprintf("packer-Resource-Group-%s", suffix)
    33  
    34  	tempName.AdminPassword = common.RandomString(TempPasswordAlphabet, 32)
    35  
    36  	return tempName
    37  }