Fixing the linting errors now required for merging
This commit is contained in:
parent
c815a5df67
commit
fd21b669db
|
@ -30,10 +30,6 @@ func (e *azureErrorDetails) isEmpty() bool {
|
|||
return e.Code == ""
|
||||
}
|
||||
|
||||
func (e *azureErrorResponse) isEmpty() bool {
|
||||
return e.ErrorDetails.isEmpty()
|
||||
}
|
||||
|
||||
func (e *azureErrorResponse) Error() string {
|
||||
var buf bytes.Buffer
|
||||
//buf.WriteString("-=-=- ERROR -=-=-")
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"strings"
|
||||
|
||||
dtl "github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
|
||||
armstorage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest/adal"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
|
@ -283,23 +282,6 @@ func (b *Builder) writeSSHPrivateKey(ui packer.Ui, debugKeyPath string) {
|
|||
}
|
||||
}
|
||||
|
||||
func equalLocation(location1, location2 string) bool {
|
||||
return strings.EqualFold(canonicalizeLocation(location1), canonicalizeLocation(location2))
|
||||
}
|
||||
|
||||
func canonicalizeLocation(location string) string {
|
||||
return strings.Replace(location, " ", "", -1)
|
||||
}
|
||||
|
||||
func (b *Builder) getBlobAccount(ctx context.Context, client *AzureClient, resourceGroupName string, storageAccountName string) (*armstorage.Account, error) {
|
||||
account, err := client.AccountsClient.GetProperties(ctx, resourceGroupName, storageAccountName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &account, err
|
||||
}
|
||||
|
||||
func (b *Builder) configureStateBag(stateBag multistep.StateBag) {
|
||||
stateBag.Put(constants.AuthorizedKey, b.config.sshAuthorizedKey)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
func TestStateBagShouldBePopulatedExpectedValues(t *testing.T) {
|
||||
var testSubject = &Builder{}
|
||||
_, _, err := testSubject.Prepare(getArmBuilderConfiguration(), getPackerConfiguration())
|
||||
_, _, err := testSubject.Prepare(getDtlBuilderConfiguration(), getPackerConfiguration())
|
||||
if err != nil {
|
||||
t.Fatalf("failed to prepare: %s", err)
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
|
||||
"github.com/hashicorp/packer/builder/azure/pkcs12"
|
||||
"github.com/hashicorp/packer/common"
|
||||
commonhelper "github.com/hashicorp/packer/helper/common"
|
||||
"github.com/hashicorp/packer/helper/communicator"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -49,17 +48,15 @@ const (
|
|||
// -> ^[^_\W][\w-._]{0,79}(?<![-.])$
|
||||
//
|
||||
// This is not an exhaustive match, but it should be extremely close.
|
||||
validResourceGroupNameRe = "^[^_\\W][\\w-._\\(\\)]{0,89}$"
|
||||
validManagedDiskName = "^[^_\\W][\\w-._)]{0,79}$"
|
||||
validResourceGroupNameRe = `^[^_\W][\w-._\(\)]{0,89}$`
|
||||
validManagedDiskName = `^[^_\W][\w-._)]{0,79}$`
|
||||
)
|
||||
|
||||
var (
|
||||
reCaptureContainerName = regexp.MustCompile("^[a-z0-9][a-z0-9\\-]{2,62}$")
|
||||
reCaptureNamePrefix = regexp.MustCompile("^[A-Za-z0-9][A-Za-z0-9_\\-\\.]{0,23}$")
|
||||
reCaptureContainerName = regexp.MustCompile(`^[a-z0-9][a-z0-9\-]{2,62}`)
|
||||
reCaptureNamePrefix = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9_\-\.]{0,23}$`)
|
||||
reManagedDiskName = regexp.MustCompile(validManagedDiskName)
|
||||
reResourceGroupName = regexp.MustCompile(validResourceGroupNameRe)
|
||||
reSnapshotName = regexp.MustCompile("^[A-Za-z0-9_]{1,79}$")
|
||||
reSnapshotPrefix = regexp.MustCompile("^[A-Za-z0-9_]{1,59}$")
|
||||
)
|
||||
|
||||
type SharedImageGallery struct {
|
||||
|
@ -222,7 +219,6 @@ type Config struct {
|
|||
// 256 characters. Tags are applied to every resource deployed by a Packer
|
||||
// build, i.e. Resource Group, VM, NIC, VNET, Public IP, KeyVault, etc.
|
||||
AzureTags map[string]*string `mapstructure:"azure_tags" required:"false"`
|
||||
storageAccountBlobEndpoint string
|
||||
|
||||
// Used for creating images from Marketplace images. Please refer to
|
||||
// [Deploy an image with Marketplace
|
||||
|
@ -294,7 +290,6 @@ type Config struct {
|
|||
tmpOSDiskName string
|
||||
tmpSubnetName string
|
||||
tmpVirtualNetworkName string
|
||||
tmpWinRMCertificateUrl string
|
||||
VMCreationResourceGroup string
|
||||
tmpFQDN string
|
||||
|
||||
|
@ -318,14 +313,6 @@ type keyVaultCertificate struct {
|
|||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Config) toVMID() string {
|
||||
var resourceGroupName string
|
||||
if c.tmpResourceGroupName != "" {
|
||||
resourceGroupName = c.tmpResourceGroupName
|
||||
}
|
||||
return fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/%s", c.ClientConfig.SubscriptionID, resourceGroupName, c.tmpComputeName)
|
||||
}
|
||||
|
||||
func (c *Config) isManagedImage() bool {
|
||||
return c.ManagedImageName != ""
|
||||
}
|
||||
|
@ -442,6 +429,7 @@ func newConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
|
||||
c.ClientConfig.Validate(errs)
|
||||
|
||||
assertRequiredParametersSet(&c, errs)
|
||||
assertTagProperties(&c, errs)
|
||||
if errs != nil && len(errs.Errors) > 0 {
|
||||
return nil, nil, errs
|
||||
|
@ -502,9 +490,13 @@ func setWinRMCertificate(c *Config) error {
|
|||
func setRuntimeValues(c *Config) {
|
||||
var tempName = NewTempName(c)
|
||||
|
||||
<<<<<<< HEAD
|
||||
c.tmpAdminPassword = "Packer~1" //tempName.AdminPassword
|
||||
// store so that we can access this later during provisioning
|
||||
commonhelper.SetSharedState("winrm_password", c.tmpAdminPassword, c.PackerConfig.PackerBuildName)
|
||||
=======
|
||||
c.tmpAdminPassword = tempName.AdminPassword
|
||||
>>>>>>> Fixing the linting errors now required for merging
|
||||
packer.LogSecretFilter.Set(c.tmpAdminPassword)
|
||||
|
||||
c.tmpCertificatePassword = "Packer~1" //tempName.CertificatePassword
|
||||
|
@ -554,8 +546,6 @@ func provideDefaultValues(c *Config) {
|
|||
if c.ImagePublisher != "" && c.ImageVersion == "" {
|
||||
c.ImageVersion = DefaultImageVersion
|
||||
}
|
||||
|
||||
c.ClientConfig.SetDefaultValues()
|
||||
}
|
||||
|
||||
func assertTagProperties(c *Config, errs *packer.MultiError) {
|
||||
|
@ -736,17 +726,6 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
|
|||
default:
|
||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The managed_image_storage_account_type %q is invalid", c.ManagedImageStorageAccountType))
|
||||
}
|
||||
|
||||
switch c.DiskCachingType {
|
||||
case string(compute.CachingTypesNone):
|
||||
c.diskCachingType = compute.CachingTypesNone
|
||||
case string(compute.CachingTypesReadOnly):
|
||||
c.diskCachingType = compute.CachingTypesReadOnly
|
||||
case "", string(compute.CachingTypesReadWrite):
|
||||
c.diskCachingType = compute.CachingTypesReadWrite
|
||||
default:
|
||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The disk_caching_type %q is invalid", c.DiskCachingType))
|
||||
}
|
||||
}
|
||||
|
||||
func assertManagedImageName(name, setting string) (bool, error) {
|
||||
|
@ -756,20 +735,6 @@ func assertManagedImageName(name, setting string) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func assertManagedImageOSDiskSnapshotName(name, setting string) (bool, error) {
|
||||
if !isValidAzureName(reSnapshotName, name) {
|
||||
return false, fmt.Errorf("The setting %s must only contain characters from a-z, A-Z, 0-9 and _ and the maximum length is 80 characters", setting)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func assertManagedImageDataDiskSnapshotName(name, setting string) (bool, error) {
|
||||
if !isValidAzureName(reSnapshotPrefix, name) {
|
||||
return false, fmt.Errorf("The setting %s must only contain characters from a-z, A-Z, 0-9 and _ and the maximum length (excluding the prefix) is 60 characters", setting)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func assertResourceGroupName(rgn, setting string) (bool, error) {
|
||||
if !isValidAzureName(reResourceGroupName, rgn) {
|
||||
return false, fmt.Errorf("The setting %s must match the regular expression %q, and not end with a '-' or '.'.", setting, validResourceGroupNameRe)
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/hashicorp/packer/builder/azure/common/constants"
|
||||
)
|
||||
|
||||
// List of configuration parameters that are required by the ARM builder.
|
||||
// List of configuration parameters that are required by the DTL builder.
|
||||
var requiredConfigValues = []string{
|
||||
"capture_name_prefix",
|
||||
"capture_container_name",
|
||||
|
@ -20,10 +20,12 @@ var requiredConfigValues = []string{
|
|||
"location",
|
||||
"os_type",
|
||||
"subscription_id",
|
||||
"lab_resource_group_name",
|
||||
"lab_virtual_network_name",
|
||||
}
|
||||
|
||||
func TestConfigShouldProvideReasonableDefaultValues(t *testing.T) {
|
||||
c, _, err := newConfig(getArmBuilderConfiguration(), getPackerConfiguration())
|
||||
c, _, err := newConfig(getDtlBuilderConfiguration(), getPackerConfiguration())
|
||||
|
||||
if err != nil {
|
||||
t.Error("Expected configuration creation to succeed, but it failed!\n")
|
||||
|
@ -52,7 +54,7 @@ func TestConfigShouldProvideReasonableDefaultValues(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConfigShouldDefaultVMSizeToStandardA1(t *testing.T) {
|
||||
c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration())
|
||||
c, _, _ := newConfig(getDtlBuilderConfiguration(), getPackerConfiguration())
|
||||
|
||||
if c.VMSize != "Standard_A1" {
|
||||
t.Errorf("Expected 'VMSize' to default to 'Standard_A1', but got '%s'.", c.VMSize)
|
||||
|
@ -60,30 +62,13 @@ func TestConfigShouldDefaultVMSizeToStandardA1(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConfigShouldDefaultImageVersionToLatest(t *testing.T) {
|
||||
c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration())
|
||||
c, _, _ := newConfig(getDtlBuilderConfiguration(), getPackerConfiguration())
|
||||
|
||||
if c.ImageVersion != "latest" {
|
||||
t.Errorf("Expected 'ImageVersion' to default to 'latest', but got '%s'.", c.ImageVersion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigShouldNotDefaultImageVersionIfCustomImage(t *testing.T) {
|
||||
config := map[string]string{
|
||||
"capture_name_prefix": "ignore",
|
||||
"capture_container_name": "ignore",
|
||||
"location": "ignore",
|
||||
"image_url": "ignore",
|
||||
"subscription_id": "ignore",
|
||||
"os_type": constants.Target_Linux,
|
||||
"communicator": "none",
|
||||
}
|
||||
|
||||
c, _, _ := newConfig(config, getPackerConfiguration())
|
||||
if c.ImageVersion != "" {
|
||||
t.Errorf("Expected 'ImageVersion' to empty, but got '%s'.", c.ImageVersion)
|
||||
}
|
||||
}
|
||||
|
||||
// The user can pass the value virtual_network_resource_group_name to avoid the lookup of
|
||||
// a virtual network's resource group, or to help with disambiguation. The value should
|
||||
// only be set if virtual_network_name was set.
|
||||
|
@ -127,7 +112,7 @@ func TestConfigVirtualNetworkSubnetNameMustBeSetWithVirtualNetworkName(t *testin
|
|||
}
|
||||
|
||||
func TestSystemShouldDefineRuntimeValues(t *testing.T) {
|
||||
c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration())
|
||||
c, _, _ := newConfig(getDtlBuilderConfiguration(), getPackerConfiguration())
|
||||
|
||||
if c.Password == "" {
|
||||
t.Errorf("Expected Password to not be empty, but it was '%s'!", c.Password)
|
||||
|
@ -151,7 +136,7 @@ func TestSystemShouldDefineRuntimeValues(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConfigShouldTransformToVirtualMachineCaptureParameters(t *testing.T) {
|
||||
c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration())
|
||||
c, _, _ := newConfig(getDtlBuilderConfiguration(), getPackerConfiguration())
|
||||
parameters := c.toVirtualMachineCaptureParameters()
|
||||
|
||||
if *parameters.DestinationContainerName != c.CaptureContainerName {
|
||||
|
@ -169,7 +154,7 @@ func TestConfigShouldTransformToVirtualMachineCaptureParameters(t *testing.T) {
|
|||
|
||||
func TestConfigShouldSupportPackersConfigElements(t *testing.T) {
|
||||
c, _, err := newConfig(
|
||||
getArmBuilderConfiguration(),
|
||||
getDtlBuilderConfiguration(),
|
||||
getPackerConfiguration(),
|
||||
getPackerCommunicatorConfiguration())
|
||||
|
||||
|
@ -187,7 +172,7 @@ func TestConfigShouldSupportPackersConfigElements(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWinRMConfigShouldSetRoundTripDecorator(t *testing.T) {
|
||||
config := getArmBuilderConfiguration()
|
||||
config := getDtlBuilderConfiguration()
|
||||
config["communicator"] = "winrm"
|
||||
config["winrm_username"] = "username"
|
||||
config["winrm_password"] = "password"
|
||||
|
@ -213,6 +198,8 @@ func TestUserDeviceLoginIsEnabledForLinux(t *testing.T) {
|
|||
"subscription_id": "ignore",
|
||||
"os_type": constants.Target_Linux,
|
||||
"communicator": "none",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
}
|
||||
|
||||
_, _, err := newConfig(config, getPackerConfiguration())
|
||||
|
@ -231,6 +218,8 @@ func TestConfigShouldAcceptTags(t *testing.T) {
|
|||
"location": "ignore",
|
||||
"subscription_id": "ignore",
|
||||
"communicator": "none",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
// Does not matter for this test case, just pick one.
|
||||
"os_type": constants.Target_Linux,
|
||||
"azure_tags": map[string]string{
|
||||
|
@ -282,6 +271,8 @@ func TestConfigShouldRejectTagsInExcessOf15AcceptTags(t *testing.T) {
|
|||
"location": "ignore",
|
||||
"subscription_id": "ignore",
|
||||
"communicator": "none",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
// Does not matter for this test case, just pick one.
|
||||
"os_type": constants.Target_Linux,
|
||||
"azure_tags": tooManyTags,
|
||||
|
@ -312,6 +303,8 @@ func TestConfigShouldRejectExcessiveTagNameLength(t *testing.T) {
|
|||
"location": "ignore",
|
||||
"subscription_id": "ignore",
|
||||
"communicator": "none",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
// Does not matter for this test case, just pick one.
|
||||
"os_type": constants.Target_Linux,
|
||||
"azure_tags": tags,
|
||||
|
@ -341,6 +334,8 @@ func TestConfigShouldRejectExcessiveTagValueLength(t *testing.T) {
|
|||
"location": "ignore",
|
||||
"subscription_id": "ignore",
|
||||
"communicator": "none",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
// Does not matter for this test case, just pick one.
|
||||
"os_type": constants.Target_Linux,
|
||||
"azure_tags": tags,
|
||||
|
@ -362,6 +357,8 @@ func TestConfigShouldAcceptPlatformManagedImageBuild(t *testing.T) {
|
|||
"communicator": "none",
|
||||
"managed_image_resource_group_name": "ignore",
|
||||
"managed_image_name": "ignore",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
|
||||
// Does not matter for this test case, just pick one.
|
||||
"os_type": constants.Target_Linux,
|
||||
|
@ -382,6 +379,8 @@ func TestConfigShouldAcceptManagedImageStorageAccountTypes(t *testing.T) {
|
|||
"communicator": "none",
|
||||
"managed_image_resource_group_name": "ignore",
|
||||
"managed_image_name": "ignore",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
|
||||
// Does not matter for this test case, just pick one.
|
||||
"os_type": constants.Target_Linux,
|
||||
|
@ -407,6 +406,8 @@ func TestConfigShouldAcceptDiskCachingTypes(t *testing.T) {
|
|||
"communicator": "none",
|
||||
"managed_image_resource_group_name": "ignore",
|
||||
"managed_image_name": "ignore",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
|
||||
// Does not matter for this test case, just pick one.
|
||||
"os_type": constants.Target_Linux,
|
||||
|
@ -433,6 +434,8 @@ func TestConfigShouldRejectTempAndBuildResourceGroupName(t *testing.T) {
|
|||
"location": "ignore",
|
||||
"subscription_id": "ignore",
|
||||
"communicator": "none",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
|
||||
// custom may define one or the other, but not both
|
||||
"temp_resource_group_name": "rgn00",
|
||||
|
@ -446,7 +449,7 @@ func TestConfigShouldRejectTempAndBuildResourceGroupName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConfigAdditionalDiskDefaultIsNil(t *testing.T) {
|
||||
c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration())
|
||||
c, _, _ := newConfig(getDtlBuilderConfiguration(), getPackerConfiguration())
|
||||
if c.AdditionalDiskSize != nil {
|
||||
t.Errorf("Expected Config to not have a set of additional disks, but got a non nil value")
|
||||
}
|
||||
|
@ -461,6 +464,8 @@ func TestConfigAdditionalDiskOverrideDefault(t *testing.T) {
|
|||
"subscription_id": "ignore",
|
||||
"os_type": constants.Target_Linux,
|
||||
"communicator": "none",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
}
|
||||
|
||||
diskconfig := map[string][]int32{
|
||||
|
@ -494,6 +499,8 @@ func TestConfigShouldAllowAsyncResourceGroupOverride(t *testing.T) {
|
|||
"managed_image_name": "ignore",
|
||||
"managed_image_resource_group_name": "ignore",
|
||||
"async_resourcegroup_delete": "true",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
}
|
||||
|
||||
c, _, err := newConfig(config, getPackerConfiguration())
|
||||
|
@ -516,6 +523,8 @@ func TestConfigShouldAllowAsyncResourceGroupOverrideNoValue(t *testing.T) {
|
|||
"os_type": "linux",
|
||||
"managed_image_name": "ignore",
|
||||
"managed_image_resource_group_name": "ignore",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
}
|
||||
|
||||
c, _, err := newConfig(config, getPackerConfiguration())
|
||||
|
@ -539,6 +548,8 @@ func TestConfigShouldAllowAsyncResourceGroupOverrideBadValue(t *testing.T) {
|
|||
"managed_image_name": "ignore",
|
||||
"managed_image_resource_group_name": "ignore",
|
||||
"async_resourcegroup_delete": "asdasda",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
}
|
||||
|
||||
c, _, err := newConfig(config, getPackerConfiguration())
|
||||
|
@ -553,6 +564,8 @@ func TestConfigShouldAllowSharedImageGalleryOptions(t *testing.T) {
|
|||
"location": "ignore",
|
||||
"subscription_id": "ignore",
|
||||
"os_type": "linux",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
"shared_image_gallery": map[string]string{
|
||||
"subscription": "ignore",
|
||||
"resource_group": "ignore",
|
||||
|
@ -585,6 +598,8 @@ func TestConfigShouldRejectSharedImageGalleryWithVhdTarget(t *testing.T) {
|
|||
"storage_account": "ignore",
|
||||
"capture_container_name": "ignore",
|
||||
"capture_name_prefix": "ignore",
|
||||
"lab_resource_group_name": "ignore",
|
||||
"lab_virtual_network_name": "ignore",
|
||||
}
|
||||
|
||||
_, _, err := newConfig(config, getPackerConfiguration())
|
||||
|
@ -593,7 +608,7 @@ func TestConfigShouldRejectSharedImageGalleryWithVhdTarget(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func getArmBuilderConfiguration() map[string]string {
|
||||
func getDtlBuilderConfiguration() map[string]string {
|
||||
m := make(map[string]string)
|
||||
for _, v := range requiredConfigValues {
|
||||
m[v] = "ignored00"
|
||||
|
@ -604,20 +619,6 @@ func getArmBuilderConfiguration() map[string]string {
|
|||
return m
|
||||
}
|
||||
|
||||
func getArmBuilderConfigurationWithWindows() map[string]string {
|
||||
m := make(map[string]string)
|
||||
for _, v := range requiredConfigValues {
|
||||
m[v] = "ignored00"
|
||||
}
|
||||
|
||||
m["object_id"] = "ignored00"
|
||||
m["tenant_id"] = "ignored00"
|
||||
m["winrm_username"] = "ignored00"
|
||||
m["communicator"] = "winrm"
|
||||
m["os_type"] = constants.Target_Windows
|
||||
return m
|
||||
}
|
||||
|
||||
func getPackerConfiguration() interface{} {
|
||||
config := map[string]interface{}{
|
||||
"packer_build_name": "azure-arm-vm",
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestPrivateKeyShouldParse(t *testing.T) {
|
|||
t.Fatalf("Failed to create a new OpenSSH key pair, err=%s.", err)
|
||||
}
|
||||
|
||||
_, err = ssh.ParsePrivateKey([]byte(testSubject.PrivateKey()))
|
||||
_, err = ssh.ParsePrivateKey(testSubject.PrivateKey())
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to parse the private key, err=%s\n", err)
|
||||
}
|
||||
|
|
|
@ -193,5 +193,4 @@ func (s *StepDeployTemplate) Cleanup(state multistep.StateBag) {
|
|||
//Only clean up if this was an existing resource group and the resource group
|
||||
//is marked as created
|
||||
// Just return now
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package dtl
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute"
|
||||
"github.com/hashicorp/packer/builder/azure/common/constants"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
|
|
|
@ -3,6 +3,7 @@ package dtl
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/packer/builder/azure/common/constants"
|
||||
commonhelper "github.com/hashicorp/packer/helper/common"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -15,7 +16,12 @@ type StepSaveWinRMPassword struct {
|
|||
|
||||
func (s *StepSaveWinRMPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
// store so that we can access this later during provisioning
|
||||
commonhelper.SetSharedState("winrm_password", s.Password, s.BuildName)
|
||||
err := commonhelper.SetSharedState("winrm_password", s.Password, s.BuildName)
|
||||
if err != nil {
|
||||
state.Put(constants.Error, err)
|
||||
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
packer.LogSecretFilter.Set(s.Password)
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
|
|
@ -1,32 +1,14 @@
|
|||
package dtl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2018-09-15/dtl"
|
||||
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources"
|
||||
"github.com/hashicorp/packer/builder/azure/common/template"
|
||||
)
|
||||
|
||||
type templateFactoryFuncDtl func(*Config) (*dtl.LabVirtualMachineCreationParameter, error)
|
||||
|
||||
func GetKeyVaultDeployment(config *Config) (*resources.Deployment, error) {
|
||||
params := &template.TemplateParameters{
|
||||
KeyVaultName: &template.TemplateParameter{Value: config.tmpKeyVaultName},
|
||||
KeyVaultSecretValue: &template.TemplateParameter{Value: config.winrmCertificate},
|
||||
ObjectId: &template.TemplateParameter{Value: config.ClientConfig.ObjectID},
|
||||
TenantId: &template.TemplateParameter{Value: config.ClientConfig.TenantID},
|
||||
}
|
||||
|
||||
builder, _ := template.NewTemplateBuilder(template.KeyVault)
|
||||
builder.SetTags(&config.AzureTags)
|
||||
|
||||
doc, _ := builder.ToJSON()
|
||||
return createDeploymentParameters(*doc, params)
|
||||
}
|
||||
|
||||
func newBool(val bool) *bool {
|
||||
b := true
|
||||
if val == b {
|
||||
|
@ -152,30 +134,3 @@ func GetVirtualMachineDeployment(config *Config) (*dtl.LabVirtualMachineCreation
|
|||
|
||||
return labMachine, nil
|
||||
}
|
||||
|
||||
func createDeploymentParameters(doc string, parameters *template.TemplateParameters) (*resources.Deployment, error) {
|
||||
var template map[string]interface{}
|
||||
err := json.Unmarshal(([]byte)(doc), &template)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bs, err := json.Marshal(*parameters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var templateParameters map[string]interface{}
|
||||
err = json.Unmarshal(bs, &templateParameters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &resources.Deployment{
|
||||
Properties: &resources.DeploymentProperties{
|
||||
Mode: resources.Incremental,
|
||||
Template: &template,
|
||||
Parameters: &templateParameters,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -14,50 +14,27 @@ import (
|
|||
"github.com/hashicorp/packer/packer/plugin"
|
||||
|
||||
alicloudecsbuilder "github.com/hashicorp/packer/builder/alicloud/ecs"
|
||||
alicloudimportpostprocessor "github.com/hashicorp/packer/post-processor/alicloud-import"
|
||||
amazonchrootbuilder "github.com/hashicorp/packer/builder/amazon/chroot"
|
||||
amazonebsbuilder "github.com/hashicorp/packer/builder/amazon/ebs"
|
||||
amazonebssurrogatebuilder "github.com/hashicorp/packer/builder/amazon/ebssurrogate"
|
||||
amazonebsvolumebuilder "github.com/hashicorp/packer/builder/amazon/ebsvolume"
|
||||
amazonimportpostprocessor "github.com/hashicorp/packer/post-processor/amazon-import"
|
||||
amazoninstancebuilder "github.com/hashicorp/packer/builder/amazon/instance"
|
||||
ansiblelocalprovisioner "github.com/hashicorp/packer/provisioner/ansible-local"
|
||||
ansibleprovisioner "github.com/hashicorp/packer/provisioner/ansible"
|
||||
artificepostprocessor "github.com/hashicorp/packer/post-processor/artifice"
|
||||
azurearmbuilder "github.com/hashicorp/packer/builder/azure/arm"
|
||||
azurechrootbuilder "github.com/hashicorp/packer/builder/azure/chroot"
|
||||
azuredtlartifactprovisioner "github.com/hashicorp/packer/provisioner/azure-dtlartifact"
|
||||
azuredtlbuilder "github.com/hashicorp/packer/builder/azure/dtl"
|
||||
breakpointprovisioner "github.com/hashicorp/packer/provisioner/breakpoint"
|
||||
checksumpostprocessor "github.com/hashicorp/packer/post-processor/checksum"
|
||||
chefclientprovisioner "github.com/hashicorp/packer/provisioner/chef-client"
|
||||
chefsoloprovisioner "github.com/hashicorp/packer/provisioner/chef-solo"
|
||||
cloudstackbuilder "github.com/hashicorp/packer/builder/cloudstack"
|
||||
compresspostprocessor "github.com/hashicorp/packer/post-processor/compress"
|
||||
convergeprovisioner "github.com/hashicorp/packer/provisioner/converge"
|
||||
digitaloceanbuilder "github.com/hashicorp/packer/builder/digitalocean"
|
||||
digitaloceanimportpostprocessor "github.com/hashicorp/packer/post-processor/digitalocean-import"
|
||||
dockerbuilder "github.com/hashicorp/packer/builder/docker"
|
||||
dockerimportpostprocessor "github.com/hashicorp/packer/post-processor/docker-import"
|
||||
dockerpushpostprocessor "github.com/hashicorp/packer/post-processor/docker-push"
|
||||
dockersavepostprocessor "github.com/hashicorp/packer/post-processor/docker-save"
|
||||
dockertagpostprocessor "github.com/hashicorp/packer/post-processor/docker-tag"
|
||||
exoscaleimportpostprocessor "github.com/hashicorp/packer/post-processor/exoscale-import"
|
||||
filebuilder "github.com/hashicorp/packer/builder/file"
|
||||
fileprovisioner "github.com/hashicorp/packer/provisioner/file"
|
||||
googlecomputebuilder "github.com/hashicorp/packer/builder/googlecompute"
|
||||
googlecomputeexportpostprocessor "github.com/hashicorp/packer/post-processor/googlecompute-export"
|
||||
googlecomputeimportpostprocessor "github.com/hashicorp/packer/post-processor/googlecompute-import"
|
||||
hcloudbuilder "github.com/hashicorp/packer/builder/hcloud"
|
||||
hyperonebuilder "github.com/hashicorp/packer/builder/hyperone"
|
||||
hypervisobuilder "github.com/hashicorp/packer/builder/hyperv/iso"
|
||||
hypervvmcxbuilder "github.com/hashicorp/packer/builder/hyperv/vmcx"
|
||||
inspecprovisioner "github.com/hashicorp/packer/provisioner/inspec"
|
||||
jdcloudbuilder "github.com/hashicorp/packer/builder/jdcloud"
|
||||
linodebuilder "github.com/hashicorp/packer/builder/linode"
|
||||
lxcbuilder "github.com/hashicorp/packer/builder/lxc"
|
||||
lxdbuilder "github.com/hashicorp/packer/builder/lxd"
|
||||
manifestpostprocessor "github.com/hashicorp/packer/post-processor/manifest"
|
||||
ncloudbuilder "github.com/hashicorp/packer/builder/ncloud"
|
||||
nullbuilder "github.com/hashicorp/packer/builder/null"
|
||||
oneandonebuilder "github.com/hashicorp/packer/builder/oneandone"
|
||||
|
@ -70,25 +47,14 @@ import (
|
|||
oscchrootbuilder "github.com/hashicorp/packer/builder/osc/chroot"
|
||||
parallelsisobuilder "github.com/hashicorp/packer/builder/parallels/iso"
|
||||
parallelspvmbuilder "github.com/hashicorp/packer/builder/parallels/pvm"
|
||||
powershellprovisioner "github.com/hashicorp/packer/provisioner/powershell"
|
||||
profitbricksbuilder "github.com/hashicorp/packer/builder/profitbricks"
|
||||
proxmoxbuilder "github.com/hashicorp/packer/builder/proxmox"
|
||||
puppetmasterlessprovisioner "github.com/hashicorp/packer/provisioner/puppet-masterless"
|
||||
puppetserverprovisioner "github.com/hashicorp/packer/provisioner/puppet-server"
|
||||
qemubuilder "github.com/hashicorp/packer/builder/qemu"
|
||||
saltmasterlessprovisioner "github.com/hashicorp/packer/provisioner/salt-masterless"
|
||||
scalewaybuilder "github.com/hashicorp/packer/builder/scaleway"
|
||||
shelllocalpostprocessor "github.com/hashicorp/packer/post-processor/shell-local"
|
||||
shelllocalprovisioner "github.com/hashicorp/packer/provisioner/shell-local"
|
||||
shellprovisioner "github.com/hashicorp/packer/provisioner/shell"
|
||||
sleepprovisioner "github.com/hashicorp/packer/provisioner/sleep"
|
||||
tencentcloudcvmbuilder "github.com/hashicorp/packer/builder/tencentcloud/cvm"
|
||||
tritonbuilder "github.com/hashicorp/packer/builder/triton"
|
||||
ucloudimportpostprocessor "github.com/hashicorp/packer/post-processor/ucloud-import"
|
||||
uclouduhostbuilder "github.com/hashicorp/packer/builder/ucloud/uhost"
|
||||
vagrantbuilder "github.com/hashicorp/packer/builder/vagrant"
|
||||
vagrantcloudpostprocessor "github.com/hashicorp/packer/post-processor/vagrant-cloud"
|
||||
vagrantpostprocessor "github.com/hashicorp/packer/post-processor/vagrant"
|
||||
virtualboxisobuilder "github.com/hashicorp/packer/builder/virtualbox/iso"
|
||||
virtualboxovfbuilder "github.com/hashicorp/packer/builder/virtualbox/ovf"
|
||||
virtualboxvmbuilder "github.com/hashicorp/packer/builder/virtualbox/vm"
|
||||
|
@ -96,12 +62,45 @@ import (
|
|||
vmwarevmxbuilder "github.com/hashicorp/packer/builder/vmware/vmx"
|
||||
vsphereclonebuilder "github.com/hashicorp/packer/builder/vsphere/clone"
|
||||
vsphereisobuilder "github.com/hashicorp/packer/builder/vsphere/iso"
|
||||
yandexbuilder "github.com/hashicorp/packer/builder/yandex"
|
||||
alicloudimportpostprocessor "github.com/hashicorp/packer/post-processor/alicloud-import"
|
||||
amazonimportpostprocessor "github.com/hashicorp/packer/post-processor/amazon-import"
|
||||
artificepostprocessor "github.com/hashicorp/packer/post-processor/artifice"
|
||||
checksumpostprocessor "github.com/hashicorp/packer/post-processor/checksum"
|
||||
compresspostprocessor "github.com/hashicorp/packer/post-processor/compress"
|
||||
digitaloceanimportpostprocessor "github.com/hashicorp/packer/post-processor/digitalocean-import"
|
||||
dockerimportpostprocessor "github.com/hashicorp/packer/post-processor/docker-import"
|
||||
dockerpushpostprocessor "github.com/hashicorp/packer/post-processor/docker-push"
|
||||
dockersavepostprocessor "github.com/hashicorp/packer/post-processor/docker-save"
|
||||
dockertagpostprocessor "github.com/hashicorp/packer/post-processor/docker-tag"
|
||||
exoscaleimportpostprocessor "github.com/hashicorp/packer/post-processor/exoscale-import"
|
||||
googlecomputeexportpostprocessor "github.com/hashicorp/packer/post-processor/googlecompute-export"
|
||||
googlecomputeimportpostprocessor "github.com/hashicorp/packer/post-processor/googlecompute-import"
|
||||
manifestpostprocessor "github.com/hashicorp/packer/post-processor/manifest"
|
||||
shelllocalpostprocessor "github.com/hashicorp/packer/post-processor/shell-local"
|
||||
ucloudimportpostprocessor "github.com/hashicorp/packer/post-processor/ucloud-import"
|
||||
vagrantpostprocessor "github.com/hashicorp/packer/post-processor/vagrant"
|
||||
vagrantcloudpostprocessor "github.com/hashicorp/packer/post-processor/vagrant-cloud"
|
||||
vspherepostprocessor "github.com/hashicorp/packer/post-processor/vsphere"
|
||||
vspheretemplatepostprocessor "github.com/hashicorp/packer/post-processor/vsphere-template"
|
||||
ansibleprovisioner "github.com/hashicorp/packer/provisioner/ansible"
|
||||
ansiblelocalprovisioner "github.com/hashicorp/packer/provisioner/ansible-local"
|
||||
azuredtlartifactprovisioner "github.com/hashicorp/packer/provisioner/azure-dtlartifact"
|
||||
breakpointprovisioner "github.com/hashicorp/packer/provisioner/breakpoint"
|
||||
chefclientprovisioner "github.com/hashicorp/packer/provisioner/chef-client"
|
||||
chefsoloprovisioner "github.com/hashicorp/packer/provisioner/chef-solo"
|
||||
convergeprovisioner "github.com/hashicorp/packer/provisioner/converge"
|
||||
fileprovisioner "github.com/hashicorp/packer/provisioner/file"
|
||||
inspecprovisioner "github.com/hashicorp/packer/provisioner/inspec"
|
||||
powershellprovisioner "github.com/hashicorp/packer/provisioner/powershell"
|
||||
puppetmasterlessprovisioner "github.com/hashicorp/packer/provisioner/puppet-masterless"
|
||||
puppetserverprovisioner "github.com/hashicorp/packer/provisioner/puppet-server"
|
||||
saltmasterlessprovisioner "github.com/hashicorp/packer/provisioner/salt-masterless"
|
||||
shellprovisioner "github.com/hashicorp/packer/provisioner/shell"
|
||||
shelllocalprovisioner "github.com/hashicorp/packer/provisioner/shell-local"
|
||||
sleepprovisioner "github.com/hashicorp/packer/provisioner/sleep"
|
||||
windowsrestartprovisioner "github.com/hashicorp/packer/provisioner/windows-restart"
|
||||
windowsshellprovisioner "github.com/hashicorp/packer/provisioner/windows-shell"
|
||||
yandexbuilder "github.com/hashicorp/packer/builder/yandex"
|
||||
|
||||
)
|
||||
|
||||
type PluginCommand struct {
|
||||
|
@ -161,7 +160,6 @@ var Builders = map[string]packer.Builder{
|
|||
"yandex": new(yandexbuilder.Builder),
|
||||
}
|
||||
|
||||
|
||||
var Provisioners = map[string]packer.Provisioner{
|
||||
"ansible": new(ansibleprovisioner.Provisioner),
|
||||
"ansible-local": new(ansiblelocalprovisioner.Provisioner),
|
||||
|
@ -183,7 +181,6 @@ var Provisioners = map[string]packer.Provisioner{
|
|||
"windows-shell": new(windowsshellprovisioner.Provisioner),
|
||||
}
|
||||
|
||||
|
||||
var PostProcessors = map[string]packer.PostProcessor{
|
||||
"alicloud-import": new(alicloudimportpostprocessor.PostProcessor),
|
||||
"amazon-import": new(amazonimportpostprocessor.PostProcessor),
|
||||
|
@ -207,7 +204,6 @@ var PostProcessors = map[string]packer.PostProcessor{
|
|||
"vsphere-template": new(vspheretemplatepostprocessor.PostProcessor),
|
||||
}
|
||||
|
||||
|
||||
var pluginRegexp = regexp.MustCompile("packer-(builder|post-processor|provisioner)-(.+)")
|
||||
|
||||
func (c *PluginCommand) Run(args []string) int {
|
||||
|
|
1
go.sum
1
go.sum
|
@ -49,6 +49,7 @@ github.com/Azure/go-autorest/autorest/date v0.2.0 h1:yW+Zlqf26583pE43KhfnhFcdmSW
|
|||
github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.3.0 h1:qJumjCaCudz+OcqE9/XtEPfvtOjOmKaui4EOpFI6zZc=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM=
|
||||
github.com/Azure/go-autorest/autorest/to v0.3.0 h1:zebkZaadz7+wIQYgC7GXaz3Wb28yKYfVkkBKwc38VF8=
|
||||
github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA=
|
||||
|
|
|
@ -683,12 +683,18 @@ go.opencensus.io/trace/internal
|
|||
go.opencensus.io/trace/propagation
|
||||
go.opencensus.io/trace/tracestate
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
# golang.org/x/crypto v0.0.0-20200117160349-530e935923ad
|
||||
golang.org/x/crypto/bcrypt
|
||||
golang.org/x/crypto/blowfish
|
||||
=======
|
||||
# golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413
|
||||
>>>>>>> Updating the module dependencies
|
||||
=======
|
||||
# golang.org/x/crypto v0.0.0-20200117160349-530e935923ad
|
||||
golang.org/x/crypto/bcrypt
|
||||
golang.org/x/crypto/blowfish
|
||||
>>>>>>> Fixing the linting errors now required for merging
|
||||
golang.org/x/crypto/chacha20
|
||||
golang.org/x/crypto/curve25519
|
||||
golang.org/x/crypto/ed25519
|
||||
|
|
Loading…
Reference in New Issue