mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
node pools: implement CLI for node pool jobs command (#17432)
This commit is contained in:
@@ -99,3 +99,26 @@ func nodePoolPredictor(factory ApiClientFactory, filter *set.Set[string]) comple
|
||||
return filtered
|
||||
})
|
||||
}
|
||||
|
||||
// nodePoolByPrefix returns a node pool that matches the given prefix or a list
|
||||
// of all matches if an exact match is not found.
|
||||
func nodePoolByPrefix(client *api.Client, prefix string) (*api.NodePool, []*api.NodePool, error) {
|
||||
pools, _, err := client.NodePools().PrefixList(prefix, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
switch len(pools) {
|
||||
case 0:
|
||||
return nil, nil, fmt.Errorf("No node pool with prefix %q found", prefix)
|
||||
case 1:
|
||||
return pools[0], nil, nil
|
||||
default:
|
||||
for _, pool := range pools {
|
||||
if pool.Name == prefix {
|
||||
return pool, nil, nil
|
||||
}
|
||||
}
|
||||
return nil, pools, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user