mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
move getInstancesByName logic to helper function
This commit is contained in:
parent
1c99825adf
commit
2b4efdea7d
@ -426,6 +426,28 @@ func (g *Cloud) AddAliasToInstance(nodeName types.NodeName, alias *net.IPNet) er
|
|||||||
// Gets the named instances, returning cloudprovider.InstanceNotFound if any
|
// Gets the named instances, returning cloudprovider.InstanceNotFound if any
|
||||||
// instance is not found
|
// instance is not found
|
||||||
func (g *Cloud) getInstancesByNames(names []string) ([]*gceInstance, error) {
|
func (g *Cloud) getInstancesByNames(names []string) ([]*gceInstance, error) {
|
||||||
|
instanceOrErrors, err := g.getInstanceOrErrorsByNames(names)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var allInstances []*gceInstance
|
||||||
|
for _, entry := range instanceOrErrors {
|
||||||
|
if entry.err != nil {
|
||||||
|
return nil, entry.err
|
||||||
|
}
|
||||||
|
allInstances = append(allInstances, entry.instance)
|
||||||
|
}
|
||||||
|
return allInstances, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type instanceOrError struct {
|
||||||
|
instance *gceInstance
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets the named instances, returning a map of each name to either the found instances or
|
||||||
|
// cloudprovider.InstanceNotFound if the instance is not found
|
||||||
|
func (g *Cloud) getInstanceOrErrorsByNames(allNames []string) (map[string]*instanceOrError, error) {
|
||||||
ctx, cancel := cloud.ContextWithCallTimeout()
|
ctx, cancel := cloud.ContextWithCallTimeout()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user