Skip to content

Commit

Permalink
pkg/destroy/aws: Remove some lastError local-variable masking
Browse files Browse the repository at this point in the history
Fixing some bugs from e24c7dc (pkg/destroy/aws: Use the
resource-groups service for tag->ARN lookup, 2019-01-10, #1039), where
I'd meant to update the delete-function-level lastError, but had
instead been creating a new local variable inside the *Pages helper.
  • Loading branch information
wking committed Mar 18, 2019
1 parent 660f2bb commit 200f0c9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/destroy/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ func deleteEC2RouteTablesByVPC(client *ec2.EC2, vpc string, logger logrus.FieldL
},
func(results *ec2.DescribeRouteTablesOutput, lastPage bool) bool {
for _, table := range results.RouteTables {
lastError := deleteEC2RouteTableObject(client, table, logger.WithField("table", *table.RouteTableId))
lastError = deleteEC2RouteTableObject(client, table, logger.WithField("table", *table.RouteTableId))
if lastError != nil {
lastError = errors.Wrapf(lastError, "deleting EC2 route table %s", *table.RouteTableId)
logger.Info(lastError)
Expand Down Expand Up @@ -1254,7 +1254,8 @@ func deleteIAMRole(client *iam.IAM, roleARN arn.ARN, logger logrus.FieldLogger)
&iam.ListInstanceProfilesForRoleInput{RoleName: &name},
func(results *iam.ListInstanceProfilesForRoleOutput, lastPage bool) bool {
for _, profile := range results.InstanceProfiles {
parsed, lastError := arn.Parse(*profile.Arn)
var parsed arn.ARN
parsed, lastError = arn.Parse(*profile.Arn)
if lastError != nil {
lastError = errors.Wrap(lastError, "parse ARN for IAM instance profile")
logger.Info(lastError)
Expand Down Expand Up @@ -1320,7 +1321,7 @@ func deleteIAMUser(client *iam.IAM, id string, logger logrus.FieldLogger) error
&iam.ListAccessKeysInput{UserName: &id},
func(results *iam.ListAccessKeysOutput, lastPage bool) bool {
for _, key := range results.AccessKeyMetadata {
_, lastError := client.DeleteAccessKey(&iam.DeleteAccessKeyInput{
_, lastError = client.DeleteAccessKey(&iam.DeleteAccessKeyInput{
UserName: &id,
AccessKeyId: key.AccessKeyId,
})
Expand Down

0 comments on commit 200f0c9

Please sign in to comment.