Skip to content

Commit 3e5b4da

Browse files
committed
Fix references to HandleErrorCode.
1 parent 29feb19 commit 3e5b4da

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

pkg/destroy/aws/aws.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func (o *ClusterUninstaller) findUntaggableResources(ctx context.Context, delete
379379
profile := fmt.Sprintf("%s-%s-profile", o.ClusterID, profileType)
380380
response, err := o.IAMClient.GetInstanceProfile(ctx, &iamv2.GetInstanceProfileInput{InstanceProfileName: &profile})
381381
if err != nil {
382-
if strings.Contains(handleErrorCode(err), "NoSuchEntity") {
382+
if strings.Contains(HandleErrorCode(err), "NoSuchEntity") {
383383
continue
384384
}
385385
return resources, fmt.Errorf("failed to get IAM instance profile: %w", err)
@@ -682,7 +682,7 @@ func deleteRoute53(ctx context.Context, client *route53.Client, arn arn.ARN, log
682682
if err != nil {
683683
// In some cases AWS may return the zone in the list of tagged resources despite the fact
684684
// it no longer exists.
685-
if strings.Contains(handleErrorCode(err), "NoSuchHostedZone") {
685+
if strings.Contains(HandleErrorCode(err), "NoSuchHostedZone") {
686686
return nil
687687
}
688688
return err
@@ -894,7 +894,7 @@ func deleteFileSystem(ctx context.Context, client *efs.Client, fsid string, logg
894894

895895
_, err = client.DeleteFileSystem(ctx, &efs.DeleteFileSystemInput{FileSystemId: aws.String(fsid)})
896896
if err != nil {
897-
if strings.Contains(handleErrorCode(err), "FileSystemNotFound") {
897+
if strings.Contains(HandleErrorCode(err), "FileSystemNotFound") {
898898
return nil
899899
}
900900
return err
@@ -953,7 +953,7 @@ func deleteAccessPoint(ctx context.Context, client *efs.Client, id string, logge
953953
logger = logger.WithField("AccessPoint ID", id)
954954
_, err := client.DeleteAccessPoint(ctx, &efs.DeleteAccessPointInput{AccessPointId: aws.String(id)})
955955
if err != nil {
956-
if strings.Contains(handleErrorCode(err), "AccessPointNotFound") {
956+
if strings.Contains(HandleErrorCode(err), "AccessPointNotFound") {
957957
return nil
958958
}
959959
return err
@@ -967,7 +967,7 @@ func deleteMountTarget(ctx context.Context, client *efs.Client, id string, logge
967967
logger = logger.WithField("Mount Target ID", id)
968968
_, err := client.DeleteMountTarget(ctx, &efs.DeleteMountTargetInput{MountTargetId: aws.String(id)})
969969
if err != nil {
970-
if strings.Contains(handleErrorCode(err), "MountTargetNotFound") {
970+
if strings.Contains(HandleErrorCode(err), "MountTargetNotFound") {
971971
return nil
972972
}
973973
return err

pkg/destroy/aws/ec2helpers.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func deleteEC2DHCPOptions(ctx context.Context, client *ec2v2.Client, id string,
172172
DhcpOptionsId: &id,
173173
})
174174
if err != nil {
175-
if handleErrorCode(err) == "InvalidDhcpOptions.NotFound" {
175+
if HandleErrorCode(err) == "InvalidDhcpOptions.NotFound" {
176176
return nil
177177
}
178178
return err
@@ -189,7 +189,7 @@ func deleteEC2Image(ctx context.Context, client *ec2v2.Client, id string, logger
189189
ImageIds: []string{id},
190190
})
191191
if err != nil {
192-
if handleErrorCode(err) == "InvalidAMI.NotFound" {
192+
if HandleErrorCode(err) == "InvalidAMI.NotFound" {
193193
return nil
194194
}
195195
return err
@@ -216,7 +216,7 @@ func deleteEC2Image(ctx context.Context, client *ec2v2.Client, id string, logger
216216
ImageId: &id,
217217
})
218218
if err != nil {
219-
if handleErrorCode(err) == "InvalidAMI.NotFound" {
219+
if HandleErrorCode(err) == "InvalidAMI.NotFound" {
220220
return nil
221221
}
222222
return err
@@ -231,7 +231,7 @@ func deleteEC2ElasticIP(ctx context.Context, client *ec2v2.Client, id string, lo
231231
AllocationId: aws.String(id),
232232
})
233233
if err != nil {
234-
if handleErrorCode(err) == "InvalidAllocation.NotFound" {
234+
if HandleErrorCode(err) == "InvalidAllocation.NotFound" {
235235
return nil
236236
}
237237
return err
@@ -246,7 +246,7 @@ func terminateEC2Instance(ctx context.Context, ec2Client *ec2v2.Client, iamClien
246246
InstanceIds: []string{id},
247247
})
248248
if err != nil {
249-
if handleErrorCode(err) == "InvalidInstance.NotFound" {
249+
if HandleErrorCode(err) == "InvalidInstance.NotFound" {
250250
return nil
251251
}
252252
return err
@@ -300,7 +300,7 @@ func deleteEC2InternetGateway(ctx context.Context, client *ec2v2.Client, id stri
300300
})
301301
if err == nil {
302302
logger.WithField("vpc", *vpc.VpcId).Debug("Detached")
303-
} else if handleErrorCode(err) == "Gateway.NotAttached" {
303+
} else if HandleErrorCode(err) == "Gateway.NotAttached" {
304304
return nil
305305
}
306306
}
@@ -322,7 +322,7 @@ func deleteEC2CarrierGateway(ctx context.Context, client *ec2v2.Client, id strin
322322
CarrierGatewayId: &id,
323323
})
324324
if err != nil {
325-
if handleErrorCode(err) == "InvalidCarrierGateway.NotFound" {
325+
if HandleErrorCode(err) == "InvalidCarrierGateway.NotFound" {
326326
return nil
327327
}
328328
return err
@@ -337,7 +337,7 @@ func deleteEC2NATGateway(ctx context.Context, client *ec2v2.Client, id string, l
337337
NatGatewayId: aws.String(id),
338338
})
339339
if err != nil {
340-
if handleErrorCode(err) == "NatGateway.NotFound" {
340+
if HandleErrorCode(err) == "NatGateway.NotFound" {
341341
return nil
342342
}
343343
return err
@@ -390,7 +390,7 @@ func deleteEC2PlacementGroup(ctx context.Context, client *ec2v2.Client, id strin
390390
GroupIds: []string{id},
391391
})
392392
if err != nil {
393-
if handleErrorCode(err) == "InvalidPlacementGroup.NotFound" {
393+
if HandleErrorCode(err) == "InvalidPlacementGroup.NotFound" {
394394
return nil
395395
}
396396
return err
@@ -413,7 +413,7 @@ func deleteEC2RouteTable(ctx context.Context, client *ec2v2.Client, id string, l
413413
RouteTableIds: []string{id},
414414
})
415415
if err != nil {
416-
if handleErrorCode(err) == "InvalidRouteTableID.NotFound" {
416+
if HandleErrorCode(err) == "InvalidRouteTableID.NotFound" {
417417
return nil
418418
}
419419
return err
@@ -543,7 +543,7 @@ func deleteEC2SecurityGroup(ctx context.Context, client *ec2v2.Client, id string
543543
GroupIds: []string{id},
544544
})
545545
if err != nil {
546-
if handleErrorCode(err) == "InvalidGroup.NotFound" {
546+
if HandleErrorCode(err) == "InvalidGroup.NotFound" {
547547
return nil
548548
}
549549
return err
@@ -593,7 +593,7 @@ func deleteEC2SecurityGroupObject(ctx context.Context, client *ec2v2.Client, gro
593593
GroupId: group.GroupId,
594594
})
595595
if err != nil {
596-
if handleErrorCode(err) == "InvalidGroup.NotFound" {
596+
if HandleErrorCode(err) == "InvalidGroup.NotFound" {
597597
return nil
598598
}
599599
return err
@@ -647,7 +647,7 @@ func deleteEC2Snapshot(ctx context.Context, client *ec2v2.Client, id string, log
647647
SnapshotId: &id,
648648
})
649649
if err != nil {
650-
if handleErrorCode(err) == "InvalidSnapshot.NotFound" {
650+
if HandleErrorCode(err) == "InvalidSnapshot.NotFound" {
651651
return nil
652652
}
653653
return err
@@ -662,7 +662,7 @@ func deleteEC2NetworkInterface(ctx context.Context, client *ec2v2.Client, id str
662662
NetworkInterfaceId: aws.String(id),
663663
})
664664
if err != nil {
665-
if handleErrorCode(err) == "InvalidNetworkInterfaceID.NotFound" {
665+
if HandleErrorCode(err) == "InvalidNetworkInterfaceID.NotFound" {
666666
return nil
667667
}
668668
return err
@@ -713,7 +713,7 @@ func deleteEC2Subnet(ctx context.Context, client *ec2v2.Client, id string, logge
713713
SubnetId: aws.String(id),
714714
})
715715
if err != nil {
716-
if handleErrorCode(err) == "InvalidSubnetID.NotFound" {
716+
if HandleErrorCode(err) == "InvalidSubnetID.NotFound" {
717717
return nil
718718
}
719719
return err
@@ -765,7 +765,7 @@ func deleteEC2Volume(ctx context.Context, client *ec2v2.Client, id string, logge
765765
VolumeId: aws.String(id),
766766
})
767767
if err != nil {
768-
if handleErrorCode(err) == "InvalidVolume.NotFound" {
768+
if HandleErrorCode(err) == "InvalidVolume.NotFound" {
769769
return nil
770770
}
771771
return err
@@ -844,7 +844,7 @@ func deleteEC2VPCEndpointsByVPC(ctx context.Context, client *ec2v2.Client, vpc s
844844
for _, endpoint := range response.VpcEndpoints {
845845
err := deleteEC2VPCEndpoint(ctx, client, *endpoint.VpcEndpointId, logger.WithField("VPC endpoint", *endpoint.VpcEndpointId))
846846
if err != nil {
847-
if handleErrorCode(err) == "InvalidVpcID.NotFound" {
847+
if HandleErrorCode(err) == "InvalidVpcID.NotFound" {
848848
return nil
849849
}
850850
return err
@@ -859,7 +859,7 @@ func deleteEC2VPCPeeringConnection(ctx context.Context, client *ec2v2.Client, id
859859
VpcPeeringConnectionId: &id,
860860
})
861861
if err != nil {
862-
if handleErrorCode(err) == "InvalidVpcPeeringConnection.NotFound" {
862+
if HandleErrorCode(err) == "InvalidVpcPeeringConnection.NotFound" {
863863
return nil
864864
}
865865
return errors.Wrapf(err, "cannot delete VPC Peering Connection %s", id)
@@ -906,7 +906,7 @@ func deleteEC2VPCEndpointService(ctx context.Context, client *ec2v2.Client, id s
906906
ServiceIds: []string{id},
907907
})
908908
if err != nil {
909-
if handleErrorCode(err) == "InvalidVpcEndpointService.NotFound" {
909+
if HandleErrorCode(err) == "InvalidVpcEndpointService.NotFound" {
910910
return nil
911911
}
912912
return errors.Wrapf(err, "cannot delete VPC Endpoint Service %s", id)

pkg/destroy/aws/elbhelpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func deleteElasticLoadBalancerListener(ctx context.Context, client *elbapiv2.Cli
111111
ListenerArn: aws.String(arn.String()),
112112
})
113113
if err != nil {
114-
if strings.Contains(handleErrorCode(err), "ListenerNotFound") {
114+
if strings.Contains(HandleErrorCode(err), "ListenerNotFound") {
115115
logger.Info("Not found or already deleted")
116116
return nil
117117
}

pkg/destroy/aws/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"github.com/pkg/errors"
66
)
77

8-
// handleErrorCode takes the error and extracts the error code if it was successfully cast as an API Error.
9-
func handleErrorCode(err error) string {
8+
// HandleErrorCode takes the error and extracts the error code if it was successfully cast as an API Error.
9+
func HandleErrorCode(err error) string {
1010
var apiErr smithy.APIError
1111
if errors.As(err, &apiErr) {
1212
return apiErr.ErrorCode()

pkg/destroy/aws/iamhelpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (search *IamRoleSearch) find(ctx context.Context) (arns []string, names []s
4646
response, err := search.Client.ListRoleTags(ctx, &iamv2.ListRoleTagsInput{RoleName: role.RoleName})
4747
if err != nil {
4848
switch {
49-
case strings.Contains(handleErrorCode(err), "NoSuchEntity"):
49+
case strings.Contains(HandleErrorCode(err), "NoSuchEntity"):
5050
// The role does not exist.
5151
// Ignore this IAM Role and donot report this error via
5252
// lastError
@@ -195,7 +195,7 @@ func deleteIAMInstanceProfileByName(ctx context.Context, client *iamv2.Client, n
195195
InstanceProfileName: name,
196196
})
197197
if err != nil {
198-
if strings.Contains(handleErrorCode(err), "NoSuchEntity") {
198+
if strings.Contains(HandleErrorCode(err), "NoSuchEntity") {
199199
return nil
200200
}
201201
return err
@@ -218,7 +218,7 @@ func deleteIAMInstanceProfile(ctx context.Context, client *iamv2.Client, profile
218218
InstanceProfileName: &name,
219219
})
220220
if err != nil {
221-
if strings.Contains(handleErrorCode(err), "NoSuchEntity") {
221+
if strings.Contains(HandleErrorCode(err), "NoSuchEntity") {
222222
return nil
223223
}
224224
return err

pkg/destroy/aws/shared.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (o *ClusterUninstaller) removeSharedTag(ctx context.Context, tagClients []*
121121
}
122122
result, err := tagClient.UntagResources(ctx, request)
123123
if err != nil {
124-
if strings.Contains(handleErrorCode(err), "InvalidParameter") {
124+
if strings.Contains(HandleErrorCode(err), "InvalidParameter") {
125125
nextTagClients = nextTagClients[:len(nextTagClients)-1]
126126
}
127127
err = errors.Wrap(err, "untag shared resources")

0 commit comments

Comments
 (0)