mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 19:23:40 +00:00
Changed to use sets utility
This commit is contained in:
parent
10f79eb490
commit
967fac0adc
@ -471,9 +471,7 @@ func (gce *GCECloud) computeHostTags(hosts []string) ([]string, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set symantics
|
tags := sets.NewString()
|
||||||
// * This will be faster for large numbers of hosts (over iterating for "contains")
|
|
||||||
set := make(map[string]bool)
|
|
||||||
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 {
|
||||||
@ -482,23 +480,17 @@ func (gce *GCECloud) computeHostTags(hosts []string) ([]string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(longest_tag) > 0 {
|
if len(longest_tag) > 0 {
|
||||||
set[longest_tag] = true
|
tags.Insert(longest_tag)
|
||||||
} else if len(set) > 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the values
|
|
||||||
tags := make([]string, 0, len(set))
|
|
||||||
for tag := range set {
|
|
||||||
tags = append(tags, tag)
|
|
||||||
}
|
|
||||||
|
|
||||||
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, nil
|
return tags.List(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateTCPLoadBalancer is an implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
|
// UpdateTCPLoadBalancer is an implementation of TCPLoadBalancer.UpdateTCPLoadBalancer.
|
||||||
|
Loading…
Reference in New Issue
Block a user