Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
671c0560
Commit
671c0560
authored
Aug 21, 2017
by
xswack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the deprecated function with the suggest function
parent
e633a160
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
32 deletions
+20
-32
aws.go
pkg/cloudprovider/providers/aws/aws.go
+15
-27
aws_loadbalancer.go
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
+2
-2
aws_routes.go
pkg/cloudprovider/providers/aws/aws_routes.go
+2
-2
aws_utils.go
pkg/cloudprovider/providers/aws/aws_utils.go
+1
-1
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
671c0560
...
...
@@ -577,18 +577,6 @@ func stringPointerArray(orig []string) []*string {
return
aws
.
StringSlice
(
orig
)
}
// isNilOrEmpty returns true if the value is nil or ""
// Deprecated: prefer aws.StringValue(x) == "" (and elimination of this check altogether where possible)
func
isNilOrEmpty
(
s
*
string
)
bool
{
return
s
==
nil
||
*
s
==
""
}
// orEmpty returns the string value, or "" if the pointer is nil
// Deprecated: prefer aws.StringValue
func
orEmpty
(
s
*
string
)
string
{
return
aws
.
StringValue
(
s
)
}
func
newEc2Filter
(
name
string
,
values
...
string
)
*
ec2
.
Filter
{
filter
:=
&
ec2
.
Filter
{
Name
:
aws
.
String
(
name
),
...
...
@@ -627,7 +615,7 @@ func (s *awsSdkEC2) DescribeInstances(request *ec2.DescribeInstancesInput) ([]*e
}
nextToken
=
response
.
NextToken
if
isNilOrEmpty
(
nextToken
)
{
if
aws
.
StringValue
(
nextToken
)
==
""
{
break
}
request
.
NextToken
=
nextToken
...
...
@@ -679,7 +667,7 @@ func (s *awsSdkEC2) DescribeVolumes(request *ec2.DescribeVolumesInput) ([]*ec2.V
results
=
append
(
results
,
response
.
Volumes
...
)
nextToken
=
response
.
NextToken
if
isNilOrEmpty
(
nextToken
)
{
if
aws
.
StringValue
(
nextToken
)
==
""
{
break
}
request
.
NextToken
=
nextToken
...
...
@@ -1098,7 +1086,7 @@ func (c *Cloud) ExternalID(nodeName types.NodeName) (string, error) {
if
instance
==
nil
{
return
""
,
cloudprovider
.
InstanceNotFound
}
return
orEmpty
(
instance
.
InstanceId
),
nil
return
aws
.
StringValue
(
instance
.
InstanceId
),
nil
}
// InstanceID returns the cloud provider ID of the node with the specified nodeName.
...
...
@@ -1112,7 +1100,7 @@ func (c *Cloud) InstanceID(nodeName types.NodeName) (string, error) {
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"getInstanceByNodeName failed for %q with %q"
,
nodeName
,
err
)
}
return
"/"
+
orEmpty
(
inst
.
Placement
.
AvailabilityZone
)
+
"/"
+
orEmpty
(
inst
.
InstanceId
),
nil
return
"/"
+
aws
.
StringValue
(
inst
.
Placement
.
AvailabilityZone
)
+
"/"
+
aws
.
StringValue
(
inst
.
InstanceId
),
nil
}
// InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID
...
...
@@ -2359,7 +2347,7 @@ func (c *Cloud) ensureSecurityGroup(name string, description string) (string, er
}
time
.
Sleep
(
1
*
time
.
Second
)
}
else
{
groupID
=
orEmpty
(
createResponse
.
GroupId
)
groupID
=
aws
.
StringValue
(
createResponse
.
GroupId
)
break
}
}
...
...
@@ -2914,13 +2902,13 @@ func (c *Cloud) EnsureLoadBalancer(clusterName string, apiService *v1.Service, n
return
nil
,
err
}
err
=
c
.
ensureLoadBalancerInstances
(
orEmpty
(
loadBalancer
.
LoadBalancerName
),
loadBalancer
.
Instances
,
instances
)
err
=
c
.
ensureLoadBalancerInstances
(
aws
.
StringValue
(
loadBalancer
.
LoadBalancerName
),
loadBalancer
.
Instances
,
instances
)
if
err
!=
nil
{
glog
.
Warningf
(
"Error registering instances with the load balancer: %q"
,
err
)
return
nil
,
err
}
glog
.
V
(
1
)
.
Infof
(
"Loadbalancer %s (%v) has DNS name %s"
,
loadBalancerName
,
serviceName
,
orEmpty
(
loadBalancer
.
DNSName
))
glog
.
V
(
1
)
.
Infof
(
"Loadbalancer %s (%v) has DNS name %s"
,
loadBalancerName
,
serviceName
,
aws
.
StringValue
(
loadBalancer
.
DNSName
))
// TODO: Wait for creation?
...
...
@@ -2947,9 +2935,9 @@ func (c *Cloud) GetLoadBalancer(clusterName string, service *v1.Service) (*v1.Lo
func
toStatus
(
lb
*
elb
.
LoadBalancerDescription
)
*
v1
.
LoadBalancerStatus
{
status
:=
&
v1
.
LoadBalancerStatus
{}
if
!
isNilOrEmpty
(
lb
.
DNSName
)
{
if
aws
.
StringValue
(
lb
.
DNSName
)
!=
""
{
var
ingress
v1
.
LoadBalancerIngress
ingress
.
Hostname
=
orEmpty
(
lb
.
DNSName
)
ingress
.
Hostname
=
aws
.
StringValue
(
lb
.
DNSName
)
status
.
Ingress
=
[]
v1
.
LoadBalancerIngress
{
ingress
}
}
...
...
@@ -3035,17 +3023,17 @@ func (c *Cloud) updateInstanceSecurityGroupsForLoadBalancer(lb *elb.LoadBalancer
// Determine the load balancer security group id
loadBalancerSecurityGroupID
:=
""
for
_
,
securityGroup
:=
range
lb
.
SecurityGroups
{
if
isNilOrEmpty
(
securityGroup
)
{
if
aws
.
StringValue
(
securityGroup
)
==
""
{
continue
}
if
loadBalancerSecurityGroupID
!=
""
{
// We create LBs with one SG
glog
.
Warningf
(
"Multiple security groups for load balancer: %q"
,
orEmpty
(
lb
.
LoadBalancerName
))
glog
.
Warningf
(
"Multiple security groups for load balancer: %q"
,
aws
.
StringValue
(
lb
.
LoadBalancerName
))
}
loadBalancerSecurityGroupID
=
*
securityGroup
}
if
loadBalancerSecurityGroupID
==
""
{
return
fmt
.
Errorf
(
"Could not determine security group for load balancer: %s"
,
orEmpty
(
lb
.
LoadBalancerName
))
return
fmt
.
Errorf
(
"Could not determine security group for load balancer: %s"
,
aws
.
StringValue
(
lb
.
LoadBalancerName
))
}
// Get the actual list of groups that allow ingress from the load-balancer
...
...
@@ -3089,7 +3077,7 @@ func (c *Cloud) updateInstanceSecurityGroupsForLoadBalancer(lb *elb.LoadBalancer
}
if
securityGroup
==
nil
{
glog
.
Warning
(
"Ignoring instance without security group: "
,
orEmpty
(
instance
.
InstanceId
))
glog
.
Warning
(
"Ignoring instance without security group: "
,
aws
.
StringValue
(
instance
.
InstanceId
))
continue
}
id
:=
aws
.
StringValue
(
securityGroup
.
GroupId
)
...
...
@@ -3205,7 +3193,7 @@ func (c *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *v1.Servic
//We don't want to delete a security group that was defined in the Cloud Configurationn.
continue
}
if
isNilOrEmpty
(
securityGroupID
)
{
if
aws
.
StringValue
(
securityGroupID
)
==
""
{
glog
.
Warning
(
"Ignoring empty security group in "
,
service
.
Name
)
continue
}
...
...
@@ -3321,7 +3309,7 @@ func (c *Cloud) getInstancesByIDs(instanceIDs []*string) (map[string]*ec2.Instan
}
for
_
,
instance
:=
range
instances
{
instanceID
:=
orEmpty
(
instance
.
InstanceId
)
instanceID
:=
aws
.
StringValue
(
instance
.
InstanceId
)
if
instanceID
==
""
{
continue
}
...
...
pkg/cloudprovider/providers/aws/aws_loadbalancer.go
View file @
671c0560
...
...
@@ -388,7 +388,7 @@ func (c *Cloud) ensureLoadBalancerHealthCheck(loadBalancer *elb.LoadBalancerDesc
expectedTarget
:=
protocol
+
":"
+
strconv
.
FormatInt
(
int64
(
port
),
10
)
+
path
if
expectedTarget
==
orEmpty
(
actual
.
Target
)
&&
if
expectedTarget
==
aws
.
StringValue
(
actual
.
Target
)
&&
expectedHealthyThreshold
==
orZero
(
actual
.
HealthyThreshold
)
&&
expectedUnhealthyThreshold
==
orZero
(
actual
.
UnhealthyThreshold
)
&&
expectedTimeout
==
orZero
(
actual
.
Timeout
)
&&
...
...
@@ -426,7 +426,7 @@ func (c *Cloud) ensureLoadBalancerInstances(loadBalancerName string, lbInstances
actual
:=
sets
.
NewString
()
for
_
,
lbInstance
:=
range
lbInstances
{
actual
.
Insert
(
orEmpty
(
lbInstance
.
InstanceId
))
actual
.
Insert
(
aws
.
StringValue
(
lbInstance
.
InstanceId
))
}
additions
:=
expected
.
Difference
(
actual
)
...
...
pkg/cloudprovider/providers/aws/aws_routes.go
View file @
671c0560
...
...
@@ -75,7 +75,7 @@ func (c *Cloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error) {
var
instanceIDs
[]
*
string
for
_
,
r
:=
range
table
.
Routes
{
instanceID
:=
orEmpty
(
r
.
InstanceId
)
instanceID
:=
aws
.
StringValue
(
r
.
InstanceId
)
if
instanceID
==
""
{
continue
...
...
@@ -146,7 +146,7 @@ func (c *Cloud) CreateRoute(clusterName string, nameHint string, route *cloudpro
// In addition to configuring the route itself, we also need to configure the instance to accept that traffic
// On AWS, this requires turning source-dest checks off
err
=
c
.
configureInstanceSourceDestCheck
(
orEmpty
(
instance
.
InstanceId
),
false
)
err
=
c
.
configureInstanceSourceDestCheck
(
aws
.
StringValue
(
instance
.
InstanceId
),
false
)
if
err
!=
nil
{
return
err
}
...
...
pkg/cloudprovider/providers/aws/aws_utils.go
View file @
671c0560
...
...
@@ -38,7 +38,7 @@ func stringSetFromPointers(in []*string) sets.String {
}
out
:=
sets
.
NewString
()
for
i
:=
range
in
{
out
.
Insert
(
orEmpty
(
in
[
i
]))
out
.
Insert
(
aws
.
StringValue
(
in
[
i
]))
}
return
out
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment