diff --git a/builder/azure/arm/artifact_test.go b/builder/azure/arm/artifact_test.go index a60e27a9d..e7900ff53 100644 --- a/builder/azure/arm/artifact_test.go +++ b/builder/azure/arm/artifact_test.go @@ -16,7 +16,7 @@ func getFakeSasUrl(name string) string { func TestArtifactString(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ @@ -57,7 +57,7 @@ func TestArtifactString(t *testing.T) { func TestArtifactProperties(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ @@ -97,7 +97,7 @@ func TestArtifactProperties(t *testing.T) { func TestArtifactOverHypenatedCaptureUri(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ @@ -134,7 +134,7 @@ func TestArtifactRejectMalformedTemplates(t *testing.T) { func TestArtifactRejectMalformedStorageUri(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 95eb8811d..ac79d2d74 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -228,7 +228,7 @@ func (b *Builder) getServicePrincipalTokens(say func(string)) (*azure.ServicePri var err error if b.config.useDeviceLogin { - servicePrincipalToken, err = packerAzureCommon.Authenticate(*b.config.cloudEnvironment, b.config.SubscriptionID, b.config.TenantID, say) + servicePrincipalToken, err = packerAzureCommon.Authenticate(*b.config.cloudEnvironment, b.config.TenantID, say) if err != nil { return nil, nil, err } diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 660dca94c..aba92b817 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -121,7 +121,7 @@ func (c *Config) toVirtualMachineCaptureParameters() *compute.VirtualMachineCapt func (c *Config) createCertificate() (string, error) { privateKey, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { - err := fmt.Errorf("Failed to Generate Private Key: %s", err) + err = fmt.Errorf("Failed to Generate Private Key: %s", err) return "", err } @@ -131,7 +131,7 @@ func (c *Config) createCertificate() (string, error) { serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) if err != nil { - err := fmt.Errorf("Failed to Generate Serial Number: %v", err) + err = fmt.Errorf("Failed to Generate Serial Number: %v", err) return "", err } diff --git a/builder/azure/arm/config_test.go b/builder/azure/arm/config_test.go index 780e02889..ae66cc09b 100644 --- a/builder/azure/arm/config_test.go +++ b/builder/azure/arm/config_test.go @@ -4,7 +4,6 @@ package arm import ( - "fmt" "strings" "testing" "time" @@ -345,7 +344,7 @@ func TestUseDeviceLoginIsDisabledForWindows(t *testing.T) { _, _, err := newConfig(config, getPackerConfiguration()) if err == nil { - t.Fatalf("Expected test to fail, but it succeeded") + t.Fatal("Expected test to fail, but it succeeded") } multiError, _ := err.(*packer.MultiError) @@ -465,7 +464,7 @@ func TestConfigShouldRejectMalformedCaptureContainerName(t *testing.T) { func getArmBuilderConfiguration() map[string]string { m := make(map[string]string) for _, v := range requiredConfigValues { - m[v] = fmt.Sprintf("ignored00") + m[v] = "ignored00" } m["communicator"] = "none" @@ -476,7 +475,7 @@ func getArmBuilderConfiguration() map[string]string { func getArmBuilderConfigurationWithWindows() map[string]string { m := make(map[string]string) for _, v := range requiredConfigValues { - m[v] = fmt.Sprintf("ignored00") + m[v] = "ignored00" } m["object_id"] = "ignored00" diff --git a/builder/azure/arm/step_capture_image_test.go b/builder/azure/arm/step_capture_image_test.go index 66a18c0df..f1fe2c06a 100644 --- a/builder/azure/arm/step_capture_image_test.go +++ b/builder/azure/arm/step_capture_image_test.go @@ -97,19 +97,19 @@ func TestStepCaptureImageShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedCaptureTemplate = stateBag.Get(constants.ArmCaptureTemplate).(*CaptureTemplate) if actualComputeName != expectedComputeName { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmComputeName' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmComputeName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualVirtualMachineCaptureParameters != expectedVirtualMachineCaptureParameters { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmVirtualMachineCaptureParameters' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmVirtualMachineCaptureParameters' from the state bag, but it did not.") } if actualCaptureTemplate != expectedCaptureTemplate { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmCaptureTemplate' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmCaptureTemplate' from the state bag, but it did not.") } } diff --git a/builder/azure/arm/step_create_resource_group_test.go b/builder/azure/arm/step_create_resource_group_test.go index 02cdac66a..ff53e59df 100644 --- a/builder/azure/arm/step_create_resource_group_test.go +++ b/builder/azure/arm/step_create_resource_group_test.go @@ -74,16 +74,16 @@ func TestStepCreateResourceGroupShouldTakeStepArgumentsFromStateBag(t *testing.T var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualLocation != expectedLocation { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } _, ok := stateBag.GetOk(constants.ArmIsResourceGroupCreated) if !ok { - t.Fatalf("Expected the step to add item to stateBag['constants.ArmIsResourceGroupCreated'], but it did not.") + t.Fatal("Expected the step to add item to stateBag['constants.ArmIsResourceGroupCreated'], but it did not.") } } diff --git a/builder/azure/arm/step_delete_resource_group_test.go b/builder/azure/arm/step_delete_resource_group_test.go index bd6bf79cc..310116d0f 100644 --- a/builder/azure/arm/step_delete_resource_group_test.go +++ b/builder/azure/arm/step_delete_resource_group_test.go @@ -63,7 +63,7 @@ func TestStepDeleteResourceGroupShouldDeleteStateBagArmResourceGroupCreated(t *t value, ok := stateBag.GetOk(constants.ArmIsResourceGroupCreated) if !ok { - t.Fatalf("Expected the resource bag value arm.IsResourceGroupCreated to exist") + t.Fatal("Expected the resource bag value arm.IsResourceGroupCreated to exist") } if value.(bool) { diff --git a/builder/azure/arm/step_deploy_template_test.go b/builder/azure/arm/step_deploy_template_test.go index 2e19ca33e..171c2659a 100644 --- a/builder/azure/arm/step_deploy_template_test.go +++ b/builder/azure/arm/step_deploy_template_test.go @@ -77,11 +77,11 @@ func TestStepDeployTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualDeploymentName != expectedDeploymentName { - t.Fatalf("Expected StepValidateTemplate to source 'constants.ArmDeploymentName' from the state bag, but it did not.") + t.Fatal("Expected StepValidateTemplate to source 'constants.ArmDeploymentName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } } diff --git a/builder/azure/arm/step_get_certificate_test.go b/builder/azure/arm/step_get_certificate_test.go index ebeb5227c..46b105291 100644 --- a/builder/azure/arm/step_get_certificate_test.go +++ b/builder/azure/arm/step_get_certificate_test.go @@ -77,10 +77,10 @@ func TestStepGetCertificateShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedKeyVaultName = stateBag.Get(constants.ArmKeyVaultName).(string) if actualKeyVaultName != expectedKeyVaultName { - t.Fatalf("Expected StepGetCertificate to source 'constants.ArmKeyVaultName' from the state bag, but it did not.") + t.Fatal("Expected StepGetCertificate to source 'constants.ArmKeyVaultName' from the state bag, but it did not.") } if actualSecretName != DefaultSecretName { - t.Fatalf("Expected StepGetCertificate to use default value for secret, but it did not.") + t.Fatal("Expected StepGetCertificate to use default value for secret, but it did not.") } expectedCertificateUrl, ok := stateBag.GetOk(constants.ArmCertificateUrl) diff --git a/builder/azure/arm/step_get_ip_address_test.go b/builder/azure/arm/step_get_ip_address_test.go index 3240083c6..8f35ad8da 100644 --- a/builder/azure/arm/step_get_ip_address_test.go +++ b/builder/azure/arm/step_get_ip_address_test.go @@ -75,11 +75,11 @@ func TestStepGetIPAddressShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedIPAddressName = stateBag.Get(constants.ArmPublicIPAddressName).(string) if actualIPAddressName != expectedIPAddressName { - t.Fatalf("Expected StepGetIPAddress to source 'constants.ArmIPAddressName' from the state bag, but it did not.") + t.Fatal("Expected StepGetIPAddress to source 'constants.ArmIPAddressName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected StepGetIPAddress to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected StepGetIPAddress to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } expectedIPAddress, ok := stateBag.GetOk(constants.SSHHost) diff --git a/builder/azure/arm/step_get_os_disk_test.go b/builder/azure/arm/step_get_os_disk_test.go index 298cb4ef4..2062fd444 100644 --- a/builder/azure/arm/step_get_os_disk_test.go +++ b/builder/azure/arm/step_get_os_disk_test.go @@ -82,11 +82,11 @@ func TestStepGetOSDiskShouldTakeValidateArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualComputeName != expectedComputeName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } expectedOSDiskVhd, ok := stateBag.GetOk(constants.ArmOSDiskVhd) diff --git a/builder/azure/arm/step_power_off_compute_test.go b/builder/azure/arm/step_power_off_compute_test.go index a3ceaa7dd..a1b8a7b37 100644 --- a/builder/azure/arm/step_power_off_compute_test.go +++ b/builder/azure/arm/step_power_off_compute_test.go @@ -75,11 +75,11 @@ func TestStepPowerOffComputeShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualComputeName != expectedComputeName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } } diff --git a/builder/azure/arm/step_test.go b/builder/azure/arm/step_test.go index f0c365bf1..b0f2bfe81 100644 --- a/builder/azure/arm/step_test.go +++ b/builder/azure/arm/step_test.go @@ -14,7 +14,7 @@ import ( func TestProcessStepResultShouldContinueForNonErrors(t *testing.T) { stateBag := new(multistep.BasicStateBag) - code := processStepResult(nil, func(error) { t.Fatalf("Should not be called!") }, stateBag) + code := processStepResult(nil, func(error) { t.Fatal("Should not be called!") }, stateBag) if _, ok := stateBag.GetOk(constants.Error); ok { t.Errorf("Error was nil, but was still in the state bag.") } @@ -49,7 +49,7 @@ func TestProcessStepResultShouldContinueOnSuccessfulTask(t *testing.T) { Err: nil, } - code := processInterruptibleResult(result, func(error) { t.Fatalf("Should not be called!") }, stateBag) + code := processInterruptibleResult(result, func(error) { t.Fatal("Should not be called!") }, stateBag) if _, ok := stateBag.GetOk(constants.Error); ok { t.Errorf("Error was nil, but was still in the state bag.") } @@ -66,7 +66,7 @@ func TestProcessStepResultShouldHaltWhenTaskIsCancelled(t *testing.T) { Err: nil, } - code := processInterruptibleResult(result, func(error) { t.Fatalf("Should not be called!") }, stateBag) + code := processInterruptibleResult(result, func(error) { t.Fatal("Should not be called!") }, stateBag) if _, ok := stateBag.GetOk(constants.Error); ok { t.Errorf("Error was nil, but was still in the state bag.") } diff --git a/builder/azure/arm/step_validate_template_test.go b/builder/azure/arm/step_validate_template_test.go index 887638aac..eb82a8848 100644 --- a/builder/azure/arm/step_validate_template_test.go +++ b/builder/azure/arm/step_validate_template_test.go @@ -75,11 +75,11 @@ func TestStepValidateTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualDeploymentName != expectedDeploymentName { - t.Fatalf("Expected the step to source 'constants.ArmDeploymentName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmDeploymentName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } } diff --git a/builder/azure/common/devicelogin.go b/builder/azure/common/devicelogin.go index d5cd259cd..5e8821f8c 100644 --- a/builder/azure/common/devicelogin.go +++ b/builder/azure/common/devicelogin.go @@ -39,7 +39,7 @@ var ( // Authenticate fetches a token from the local file cache or initiates a consent // flow and waits for token to be obtained. -func Authenticate(env azure.Environment, subscriptionID, tenantID string, say func(string)) (*azure.ServicePrincipalToken, error) { +func Authenticate(env azure.Environment, tenantID string, say func(string)) (*azure.ServicePrincipalToken, error) { clientID, ok := clientIDs[env.Name] if !ok { return nil, fmt.Errorf("packer-azure application not set up for Azure environment %q", env.Name) @@ -81,7 +81,7 @@ func Authenticate(env azure.Environment, subscriptionID, tenantID string, say fu // will go stale every 14 days and we will delete the token file, // re-initiate the device flow. say("Validating the token.") - if err := validateToken(env, spt); err != nil { + if err = validateToken(env, spt); err != nil { say(fmt.Sprintf("Error: %v", err)) say("Stored Azure credentials expired. Please reauthenticate.") say(fmt.Sprintf("Deleting %s", tokenPath)) @@ -96,7 +96,7 @@ func Authenticate(env azure.Environment, subscriptionID, tenantID string, say fu // Start an OAuth 2.0 device flow say(fmt.Sprintf("Initiating device flow: %s", tokenPath)) - spt, err = tokenFromDeviceFlow(say, *oauthCfg, tokenPath, clientID, apiScope) + spt, err = tokenFromDeviceFlow(say, *oauthCfg, clientID, apiScope) if err != nil { return nil, err } @@ -136,7 +136,7 @@ func tokenFromFile(say func(string), oauthCfg azure.OAuthConfig, tokenPath, clie // consent application on a browser and in the meanwhile the authentication // endpoint is polled until user gives consent, denies or the flow times out. // Returned token must be saved. -func tokenFromDeviceFlow(say func(string), oauthCfg azure.OAuthConfig, tokenPath, clientID, resource string) (*azure.ServicePrincipalToken, error) { +func tokenFromDeviceFlow(say func(string), oauthCfg azure.OAuthConfig, clientID, resource string) (*azure.ServicePrincipalToken, error) { cl := autorest.NewClientWithUserAgent(userAgent) deviceCode, err := azure.InitiateDeviceAuth(&cl, oauthCfg, clientID, resource) if err != nil { diff --git a/builder/azure/common/interruptible_task_test.go b/builder/azure/common/interruptible_task_test.go index 22a969700..44e849f62 100644 --- a/builder/azure/common/interruptible_task_test.go +++ b/builder/azure/common/interruptible_task_test.go @@ -20,7 +20,7 @@ func TestInterruptibleTaskShouldImmediatelyEndOnCancel(t *testing.T) { result := testSubject.Run() if result.IsCancelled != true { - t.Fatalf("Expected the task to be cancelled, but it was not.") + t.Fatal("Expected the task to be cancelled, but it was not.") } } diff --git a/builder/azure/common/lin/step_create_cert.go b/builder/azure/common/lin/step_create_cert.go index d8b7ef48a..08b60f45a 100644 --- a/builder/azure/common/lin/step_create_cert.go +++ b/builder/azure/common/lin/step_create_cert.go @@ -32,7 +32,7 @@ func (s *StepCreateCert) Run(state multistep.StateBag) multistep.StepAction { err := s.createCert(state) if err != nil { - err := fmt.Errorf("Error creating temporary certificate: %s", err) + err = fmt.Errorf("Error creating temporary certificate: %s", err) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt @@ -45,11 +45,11 @@ func (s *StepCreateCert) Cleanup(state multistep.StateBag) {} func (s *StepCreateCert) createCert(state multistep.StateBag) error { - log.Printf("createCert: Generating RSA key pair...") + log.Println("createCert: Generating RSA key pair...") priv, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { - err := fmt.Errorf("Failed to Generate Private Key: %s", err) + err = fmt.Errorf("Failed to Generate Private Key: %s", err) return err } @@ -63,7 +63,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error { state.Put(constants.PrivateKey, privkey) log.Printf("createCert: Private key:\n%s", privkey) - log.Printf("createCert: Creating certificate...") + log.Println("createCert: Creating certificate...") host := fmt.Sprintf("%s.cloudapp.net", s.TmpServiceName) notBefore := time.Now() @@ -71,7 +71,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error { serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) if err != nil { - err := fmt.Errorf("Failed to Generate Serial Number: %v", err) + err = fmt.Errorf("Failed to Generate Serial Number: %v", err) return err } @@ -93,7 +93,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error { derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) if err != nil { - err := fmt.Errorf("Failed to Create Certificate: %s", err) + err = fmt.Errorf("Failed to Create Certificate: %s", err) return err } diff --git a/builder/azure/common/lin/step_generalize_os.go b/builder/azure/common/lin/step_generalize_os.go index f377cb3e3..e36d39009 100644 --- a/builder/azure/common/lin/step_generalize_os.go +++ b/builder/azure/common/lin/step_generalize_os.go @@ -29,7 +29,7 @@ func (s *StepGeneralizeOS) Run(state multistep.StateBag) multistep.StepAction { } if err := comm.Start(cmd); err != nil { - err := fmt.Errorf("Failed executing OS generalization command: %s", err) + err = fmt.Errorf("Failed executing OS generalization command: %s", err) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt diff --git a/builder/azure/common/template/template_builder.go b/builder/azure/common/template/template_builder.go index 0b0ba1809..d69d782e7 100644 --- a/builder/azure/common/template/template_builder.go +++ b/builder/azure/common/template/template_builder.go @@ -46,7 +46,7 @@ func (s *TemplateBuilder) BuildLinux(sshAuthorizedKey string) error { profile.LinuxConfiguration = &compute.LinuxConfiguration{ SSH: &compute.SSHConfiguration{ PublicKeys: &[]compute.SSHPublicKey{ - compute.SSHPublicKey{ + { Path: to.StringPtr(s.toVariable(variableSshKeyPath)), KeyData: to.StringPtr(sshAuthorizedKey), }, @@ -66,12 +66,12 @@ func (s *TemplateBuilder) BuildWindows(keyVaultName, winRMCertificateUrl string) profile := resource.Properties.OsProfile profile.Secrets = &[]compute.VaultSecretGroup{ - compute.VaultSecretGroup{ + { SourceVault: &compute.SubResource{ ID: to.StringPtr(s.toResourceID(resourceKeyVaults, keyVaultName)), }, VaultCertificates: &[]compute.VaultCertificate{ - compute.VaultCertificate{ + { CertificateStore: to.StringPtr("My"), CertificateURL: to.StringPtr(winRMCertificateUrl), }, @@ -83,7 +83,7 @@ func (s *TemplateBuilder) BuildWindows(keyVaultName, winRMCertificateUrl string) ProvisionVMAgent: to.BoolPtr(true), WinRM: &compute.WinRMConfiguration{ Listeners: &[]compute.WinRMListener{ - compute.WinRMListener{ + { Protocol: "https", CertificateURL: to.StringPtr(winRMCertificateUrl), }, diff --git a/builder/azure/common/template/template_parameters_test.go b/builder/azure/common/template/template_parameters_test.go index b3bedfcff..d9f12ad82 100644 --- a/builder/azure/common/template/template_parameters_test.go +++ b/builder/azure/common/template/template_parameters_test.go @@ -12,13 +12,13 @@ import ( func TestTemplateParametersShouldHaveExpectedKeys(t *testing.T) { params := TemplateParameters{ - AdminUsername: &TemplateParameter{"sentinel"}, - AdminPassword: &TemplateParameter{"sentinel"}, - DnsNameForPublicIP: &TemplateParameter{"sentinel"}, - OSDiskName: &TemplateParameter{"sentinel"}, - StorageAccountBlobEndpoint: &TemplateParameter{"sentinel"}, - VMName: &TemplateParameter{"sentinel"}, - VMSize: &TemplateParameter{"sentinel"}, + AdminUsername: &TemplateParameter{Value: "sentinel"}, + AdminPassword: &TemplateParameter{Value: "sentinel"}, + DnsNameForPublicIP: &TemplateParameter{Value: "sentinel"}, + OSDiskName: &TemplateParameter{Value: "sentinel"}, + StorageAccountBlobEndpoint: &TemplateParameter{Value: "sentinel"}, + VMName: &TemplateParameter{Value: "sentinel"}, + VMSize: &TemplateParameter{Value: "sentinel"}, } bs, err := json.Marshal(params) @@ -53,13 +53,13 @@ func TestTemplateParametersShouldHaveExpectedKeys(t *testing.T) { func TestParameterValuesShouldBeSet(t *testing.T) { params := TemplateParameters{ - AdminUsername: &TemplateParameter{"adminusername00"}, - AdminPassword: &TemplateParameter{"adminpassword00"}, - DnsNameForPublicIP: &TemplateParameter{"dnsnameforpublicip00"}, - OSDiskName: &TemplateParameter{"osdiskname00"}, - StorageAccountBlobEndpoint: &TemplateParameter{"storageaccountblobendpoint00"}, - VMName: &TemplateParameter{"vmname00"}, - VMSize: &TemplateParameter{"vmsize00"}, + AdminUsername: &TemplateParameter{Value: "adminusername00"}, + AdminPassword: &TemplateParameter{Value: "adminpassword00"}, + DnsNameForPublicIP: &TemplateParameter{Value: "dnsnameforpublicip00"}, + OSDiskName: &TemplateParameter{Value: "osdiskname00"}, + StorageAccountBlobEndpoint: &TemplateParameter{Value: "storageaccountblobendpoint00"}, + VMName: &TemplateParameter{Value: "vmname00"}, + VMSize: &TemplateParameter{Value: "vmsize00"}, } bs, err := json.Marshal(params) @@ -89,7 +89,7 @@ func TestParameterValuesShouldBeSet(t *testing.T) { func TestEmptyValuesShouldBeOmitted(t *testing.T) { params := TemplateParameters{ - AdminUsername: &TemplateParameter{"adminusername00"}, + AdminUsername: &TemplateParameter{Value: "adminusername00"}, } bs, err := json.Marshal(params) diff --git a/builder/azure/common/vault.go b/builder/azure/common/vault.go index 27909958a..e0eea671c 100644 --- a/builder/azure/common/vault.go +++ b/builder/azure/common/vault.go @@ -25,8 +25,8 @@ type VaultClient struct { } type Secret struct { - ID *string `json:"id,omitempty"` - Value string `json:"value"` + ID *string `json:"id,omitempty"` + Value string `json:"value"` } func (client *VaultClient) GetSecret(vaultName, secretName string) (*Secret, error) { diff --git a/builder/azure/pkcs12/bmp-string_test.go b/builder/azure/pkcs12/bmp-string_test.go index 85dd96fb4..fcbc7b7b1 100644 --- a/builder/azure/pkcs12/bmp-string_test.go +++ b/builder/azure/pkcs12/bmp-string_test.go @@ -29,7 +29,7 @@ func decodeBMPString(bmpString []byte) (string, error) { func TestBMPStringDecode(t *testing.T) { _, err := decodeBMPString([]byte("a")) if err == nil { - t.Fatalf("expected decode to fail, but it succeeded") + t.Fatal("expected decode to fail, but it succeeded") } } diff --git a/builder/azure/pkcs12/pkcs12.go b/builder/azure/pkcs12/pkcs12.go index 5772b2d4d..316c2e731 100644 --- a/builder/azure/pkcs12/pkcs12.go +++ b/builder/azure/pkcs12/pkcs12.go @@ -200,7 +200,7 @@ func makeSalt(saltByteCount int) ([]byte, error) { // // derBytes is a DER encoded certificate. // privateKey is an RSA -func Encode(derBytes []byte, privateKey interface{}, password string) (pfxBytes []byte, err error) { +func Encode(derBytes []byte, privateKey interface{}, password string) ([]byte, error) { secret, err := bmpString(password) if err != nil { return nil, ErrIncorrectPassword diff --git a/builder/azure/pkcs12/pkcs12_test.go b/builder/azure/pkcs12/pkcs12_test.go index b48e618a0..2cfbc44d8 100644 --- a/builder/azure/pkcs12/pkcs12_test.go +++ b/builder/azure/pkcs12/pkcs12_test.go @@ -25,7 +25,7 @@ func TestPfxRoundTriRsa(t *testing.T) { actualPrivateKey, ok := key.(*rsa.PrivateKey) if !ok { - t.Fatalf("failed to decode private key") + t.Fatal("failed to decode private key") } if privateKey.D.Cmp(actualPrivateKey.D) != 0 { diff --git a/builder/azure/pkcs12/pkcs8.go b/builder/azure/pkcs12/pkcs8.go index 1eb8850f9..5203d394f 100644 --- a/builder/azure/pkcs12/pkcs8.go +++ b/builder/azure/pkcs12/pkcs8.go @@ -28,7 +28,7 @@ var ( // marshalPKCS8PrivateKey converts a private key to PKCS#8 encoded form. // See http://www.rsa.com/rsalabs/node.asp?id=2130 and RFC5208. -func marshalPKCS8PrivateKey(key interface{}) (der []byte, err error) { +func marshalPKCS8PrivateKey(key interface{}) ([]byte, error) { pkcs := pkcs8{ Version: 0, } diff --git a/builder/azure/pkcs12/pkcs8_test.go b/builder/azure/pkcs12/pkcs8_test.go index 7d12119f5..1f891ef80 100644 --- a/builder/azure/pkcs12/pkcs8_test.go +++ b/builder/azure/pkcs12/pkcs8_test.go @@ -35,7 +35,7 @@ func TestRoundTripPkcs8Rsa(t *testing.T) { } if actualPrivateKey.Validate() != nil { - t.Fatalf("private key did not validate") + t.Fatal("private key did not validate") } if actualPrivateKey.N.Cmp(privateKey.N) != 0 { diff --git a/builder/azure/pkcs12/safebags_test.go b/builder/azure/pkcs12/safebags_test.go index bb30d4e55..384dd5ce3 100644 --- a/builder/azure/pkcs12/safebags_test.go +++ b/builder/azure/pkcs12/safebags_test.go @@ -97,6 +97,6 @@ func TestRoundTripPkcs8ShroudedKeyBag(t *testing.T) { actualPrivateKey := key.(*rsa.PrivateKey) if actualPrivateKey.D.Cmp(privateKey.D) != 0 { - t.Fatalf("failed to round-trip rsa.PrivateKey.D") + t.Fatal("failed to round-trip rsa.PrivateKey.D") } }