@@ -31,7 +31,6 @@ import (
31
31
func (vpcs * VPCSession ) GetSecurityGroupForVolumeAccessPoint (securityGroupRequest provider.SecurityGroupRequest ) (string , error ) {
32
32
vpcs .Logger .Info ("Entry of GetSecurityGroupForVolumeAccessPoint method..." , zap .Reflect ("securityGroupRequest" , securityGroupRequest ))
33
33
defer vpcs .Logger .Info ("Exit from GetSecurityGroupForVolumeAccessPoint method..." )
34
- var err error
35
34
36
35
// Get SecurityGroup by VPC and name. This is inefficient operation which requires iteration over SecurityGroup list
37
36
securityGroup , err := vpcs .getSecurityGroupByVPCAndSecurityGroupName (securityGroupRequest )
@@ -57,14 +56,12 @@ func (vpcs *VPCSession) getSecurityGroupByVPCAndSecurityGroupName(securityGroupR
57
56
58
57
if err != nil {
59
58
// API call is failed
60
- userErr := userError .GetUserError ("ListSecurityGroupsFailed" , err )
61
- return "" , userErr
59
+ return "" , userError .GetUserError ("ListSecurityGroupsFailed" , err )
62
60
}
63
61
64
62
// Iterate over the SecurityGroup list for given volume
65
63
if securityGroups != nil {
66
- securityGroupList := securityGroups .SecurityGroups
67
- for _ , securityGroupItem := range securityGroupList {
64
+ for _ , securityGroupItem := range securityGroups .SecurityGroups {
68
65
// Check if securityGroup is matching with requested input securityGroup name
69
66
if strings .EqualFold (securityGroupRequest .Name , securityGroupItem .Name ) {
70
67
vpcs .Logger .Info ("Successfully found securityGroup" , zap .Reflect ("securityGroupItem" , securityGroupItem ))
@@ -80,23 +77,22 @@ func (vpcs *VPCSession) getSecurityGroupByVPCAndSecurityGroupName(securityGroupR
80
77
startUrl , err := url .Parse (securityGroups .Next .Href )
81
78
if err != nil {
82
79
// API call is failed
83
- userErr := userError . GetUserError ( "NextSecurityGroupPageParsingError " , err , securityGroups .Next .Href )
84
- return "" , userErr
80
+ vpcs . Logger . Error ( "The next parameter of the securityGroup list could not be parsed." , zap . Reflect ( "Next " , securityGroups .Next .Href ), zap . Error ( err ) )
81
+ return "" , userError . GetUserError ( string ( "SecurityGroupFindFailedWithVPCAndSecurityGroupName" ), err , securityGroupRequest . Name )
85
82
}
86
83
87
84
vpcs .Logger .Info ("startUrl" , zap .Reflect ("startUrl" , startUrl ))
88
85
start = startUrl .Query ().Get ("start" ) //parse query param into map
89
86
if start == "" {
90
87
// API call is failed
91
- userErr := userError . GetUserError ( "StartSecurityGroupIDEmpty " , err , startUrl )
92
- return "" , userErr
88
+ vpcs . Logger . Error ( "The start specified in the next parameter of the securityGroup list is empty." , zap . Reflect ( "startUrl " , startUrl ) )
89
+ return "" , userError . GetUserError ( string ( "SecurityGroupFindFailedWithVPCAndSecurityGroupName" ), errors . New ( "no securityGroup found" ), securityGroupRequest . Name )
93
90
}
94
91
95
92
}
96
93
}
97
94
98
95
// No volume SecurityGroup found in the list. So return error
99
- userErr := userError .GetUserError (string ("SecurityGroupFindFailedWithVPCAndSecurityGroupName" ), errors .New ("no securityGroup found" ), securityGroupRequest .Name )
100
96
vpcs .Logger .Error ("SecurityGroup not found" , zap .Error (err ))
101
- return "" , userErr
97
+ return "" , userError . GetUserError ( string ( "SecurityGroupFindFailedWithVPCAndSecurityGroupName" ), errors . New ( "no securityGroup found" ), securityGroupRequest . Name )
102
98
}
0 commit comments