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
aef8ba00
Commit
aef8ba00
authored
Sep 23, 2015
by
Kenneth Shelton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ran gofmt -s
parent
967fac0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
22 deletions
+22
-22
gce.go
pkg/cloudprovider/providers/gce/gce.go
+22
-22
No files found.
pkg/cloudprovider/providers/gce/gce.go
View file @
aef8ba00
...
@@ -453,18 +453,18 @@ func (gce *GCECloud) EnsureTCPLoadBalancer(name, region string, loadBalancerIP n
...
@@ -453,18 +453,18 @@ func (gce *GCECloud) EnsureTCPLoadBalancer(name, region string, loadBalancerIP n
return
status
,
nil
return
status
,
nil
}
}
// We grab all tags from all instances being added to the pool.
// We grab all tags from all instances being added to the pool.
// * The longest tag that is a prefix of the instance name is used
// * The longest tag that is a prefix of the instance name is used
// * If any instance has a prefix tag, all instances must
// * If any instance has a prefix tag, all instances must
// * If no instances have a prefix tag, no tags are used
// * If no instances have a prefix tag, no tags are used
func
(
gce
*
GCECloud
)
computeHostTags
(
hosts
[]
string
)
([]
string
,
error
)
{
func
(
gce
*
GCECloud
)
computeHostTags
(
hosts
[]
string
)
([]
string
,
error
)
{
listCall
:=
gce
.
service
.
Instances
.
List
(
gce
.
projectID
,
gce
.
zone
)
listCall
:=
gce
.
service
.
Instances
.
List
(
gce
.
projectID
,
gce
.
zone
)
// Add the filter for hosts
// Add the filter for hosts
listCall
=
listCall
.
Filter
(
"name eq ("
+
strings
.
Join
(
hosts
,
"|"
)
+
")"
)
listCall
=
listCall
.
Filter
(
"name eq ("
+
strings
.
Join
(
hosts
,
"|"
)
+
")"
)
// Add the fields we want
// Add the fields we want
listCall
=
listCall
.
Fields
(
"items(name,tags)"
)
listCall
=
listCall
.
Fields
(
"items(name,tags)"
)
res
,
err
:=
listCall
.
Do
()
res
,
err
:=
listCall
.
Do
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -472,23 +472,23 @@ func (gce *GCECloud) computeHostTags(hosts []string) ([]string, error) {
...
@@ -472,23 +472,23 @@ func (gce *GCECloud) computeHostTags(hosts []string) ([]string, error) {
}
}
tags
:=
sets
.
NewString
()
tags
:=
sets
.
NewString
()
for
_
,
instance
:=
range
res
.
Items
{
for
_
,
instance
:=
range
res
.
Items
{
longest_tag
:=
""
longest_tag
:=
""
for
_
,
tag
:=
range
instance
.
Tags
.
Items
{
for
_
,
tag
:=
range
instance
.
Tags
.
Items
{
if
strings
.
HasPrefix
(
instance
.
Name
,
tag
)
&&
len
(
tag
)
>
len
(
longest_tag
)
{
if
strings
.
HasPrefix
(
instance
.
Name
,
tag
)
&&
len
(
tag
)
>
len
(
longest_tag
)
{
longest_tag
=
tag
longest_tag
=
tag
}
}
}
}
if
len
(
longest_tag
)
>
0
{
if
len
(
longest_tag
)
>
0
{
tags
.
Insert
(
longest_tag
)
tags
.
Insert
(
longest_tag
)
}
else
if
len
(
tags
)
>
0
{
}
else
if
len
(
tags
)
>
0
{
return
nil
,
fmt
.
Errorf
(
"Some, but not all, instances have prefix tags (%s is missing)"
,
instance
.
Name
)
return
nil
,
fmt
.
Errorf
(
"Some, but not all, instances have prefix tags (%s is missing)"
,
instance
.
Name
)
}
}
}
}
if
len
(
tags
)
==
0
{
if
len
(
tags
)
==
0
{
glog
.
V
(
2
)
.
Info
(
"No instances had tags, creating rule without target tags"
)
glog
.
V
(
2
)
.
Info
(
"No instances had tags, creating rule without target tags"
)
}
}
return
tags
.
List
(),
nil
return
tags
.
List
(),
nil
}
}
...
...
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