Skip to content

Commit

Permalink
Align style across predictors
Browse files Browse the repository at this point in the history
  • Loading branch information
davemay99 committed Oct 12, 2021
1 parent ce62ab3 commit 0feff66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion command/job_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *JobDispatchCommand) AutocompleteArgs() complete.Predictor {

resp, _, err := client.Jobs().PrefixList(a.Last)
if err != nil {
return nil
return []string{}
}

// filter by parameterized jobs
Expand Down
11 changes: 8 additions & 3 deletions command/operator_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ func NodeClassPredictor(factory ApiClientFactory) complete.Predictor {
if err != nil {
return nil
}
nodes, _, _ := client.Nodes().List(nil) // TODO: should be *api.QueryOptions that matches region, namespace

nodes, _, err := client.Nodes().List(nil) // TODO: should be *api.QueryOptions that matches region
if err != nil {
return []string{}
}

// Build map of unique node classes across all nodes
classes := make(map[string]bool)
Expand All @@ -241,7 +245,7 @@ func NodeClassPredictor(factory ApiClientFactory) complete.Predictor {
}

// ServerPredictor returns a server member predictor
// TODO: Consider API options for node class filtering
// TODO: Consider API options for server member filtering
func ServerPredictor(factory ApiClientFactory) complete.Predictor {
return complete.PredictFunc(func(a complete.Args) []string {
client, err := factory()
Expand All @@ -253,13 +257,14 @@ func ServerPredictor(factory ApiClientFactory) complete.Predictor {
return []string{}
}

// Iterate over server members looking for match
filtered := []string{}

for _, member := range members.Members {
if strings.HasPrefix(member.Name, a.Last) {
filtered = append(filtered, member.Name)
}
}

return filtered
})
}
Expand Down

0 comments on commit 0feff66

Please sign in to comment.