From 5b35d199da02385ecfe820f9693fc7af71249605 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 31 May 2017 12:27:45 -0700 Subject: [PATCH] golang has different style than python --- builder/amazon/common/ami_config.go | 16 +++++++-------- builder/amazon/common/step_ami_region_copy.go | 20 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/builder/amazon/common/ami_config.go b/builder/amazon/common/ami_config.go index 295dce09b..6fd884412 100644 --- a/builder/amazon/common/ami_config.go +++ b/builder/amazon/common/ami_config.go @@ -66,11 +66,11 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error { // Make sure that if we have region_kms_key_ids defined the regions in ami_regions are also in region_kms_key_ids if len(c.AMIRegionKmsKeyIds) > 0 { - regions_in_key_map := make([]string, 0, len(c.AMIRegionKmsKeyIds)) + regionsInKeyMap := make([]string, 0, len(c.AMIRegionKmsKeyIds)) for reg := range c.AMIRegionKmsKeyIds { - regions_in_key_map = append(regions_in_key_map, reg) + regionsInKeyMap = append(regionsInKeyMap, reg) } - if regions_match := stringInSlice(region, regions_in_key_map); !regions_match { + if regionsMatch := stringInSlice(region, regionsInKeyMap); !regionsMatch { errs = append(errs, fmt.Errorf("Region %s is in ami_regions but not in region_kms_key_ids", region)) } } @@ -82,9 +82,9 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error { } // Make sure that if we have region_kms_key_ids defined the regions in region_kms_key_ids are also in ami_regions if len(c.AMIRegionKmsKeyIds) > 0 { - for KMS_key_region := range c.AMIRegionKmsKeyIds { - if regions_match := stringInSlice(KMS_key_region, c.AMIRegions); !regions_match { - errs = append(errs, fmt.Errorf("Region %s is in region_kms_key_ids but not in ami_regions", KMS_key_region)) + for kmsKeyRegion := range c.AMIRegionKmsKeyIds { + if regionsMatch := stringInSlice(kmsKeyRegion, c.AMIRegions); !regionsMatch { + errs = append(errs, fmt.Errorf("Region %s is in region_kms_key_ids but not in ami_regions", kmsKeyRegion)) } } } @@ -98,8 +98,8 @@ func (c *AMIConfig) Prepare(ctx *interpolate.Context) []error { errs = append(errs, fmt.Errorf("Cannot share snapshot encrypted with default KMS key")) } if len(c.AMIRegionKmsKeyIds) > 0 { - for _, KMS_key_region := range c.AMIRegionKmsKeyIds { - if len(KMS_key_region) == 0 { + for _, kmsKeyRegion := range c.AMIRegionKmsKeyIds { + if len(kmsKeyRegion) == 0 { errs = append(errs, fmt.Errorf("Cannot share snapshot encrypted with default KMS key")) } } diff --git a/builder/amazon/common/step_ami_region_copy.go b/builder/amazon/common/step_ami_region_copy.go index dae550ee1..37fec8be2 100644 --- a/builder/amazon/common/step_ami_region_copy.go +++ b/builder/amazon/common/step_ami_region_copy.go @@ -35,7 +35,7 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction { var lock sync.Mutex var wg sync.WaitGroup - var reg_key_id string + var regKeyID string errs := new(packer.MultiError) for _, region := range s.Regions { if region == *ec2conn.Config.Region { @@ -47,14 +47,14 @@ func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction { wg.Add(1) ui.Message(fmt.Sprintf("Copying to: %s", region)) - reg_key_id = s.RegionKeyIds[region] + regKeyID = s.RegionKeyIds[region] if !s.EncryptBootVolume { - reg_key_id = "" + regKeyID = "" } go func(region string) { defer wg.Done() - id, snapshotIds, err := amiRegionCopy(state, s.AccessConfig, s.Name, ami, region, *ec2conn.Config.Region, reg_key_id) + id, snapshotIds, err := amiRegionCopy(state, s.AccessConfig, s.Name, ami, region, *ec2conn.Config.Region, regKeyID) lock.Lock() defer lock.Unlock() amis[region] = id @@ -87,9 +87,9 @@ func (s *StepAMIRegionCopy) Cleanup(state multistep.StateBag) { // amiRegionCopy does a copy for the given AMI to the target region and // returns the resulting ID and snapshot IDs, or error. func amiRegionCopy(state multistep.StateBag, config *AccessConfig, name string, imageId string, - target string, source string, key_id string) (string, []string, error) { + target string, source string, keyID string) (string, []string, error) { snapshotIds := []string{} - is_encrypted := false + isEncrypted := false // Connect to the region where the AMI will be copied to awsConfig, err := config.Config() @@ -104,15 +104,15 @@ func amiRegionCopy(state multistep.StateBag, config *AccessConfig, name string, } regionconn := ec2.New(session) // if we've provided a map of key ids to regions, use those keys. - if len(key_id) > 0 { - is_encrypted = true + if len(keyID) > 0 { + isEncrypted = true } resp, err := regionconn.CopyImage(&ec2.CopyImageInput{ SourceRegion: &source, SourceImageId: &imageId, Name: &name, - Encrypted: aws.Bool(is_encrypted), - KmsKeyId: aws.String(key_id), + Encrypted: aws.Bool(isEncrypted), + KmsKeyId: aws.String(keyID), }) if err != nil {