From 0feff66521a5d32ef753d409b789b892942d9419 Mon Sep 17 00:00:00 2001 From: davemay99 Date: Tue, 12 Oct 2021 17:54:05 -0400 Subject: [PATCH] Align style across predictors --- command/job_dispatch.go | 2 +- command/operator_debug.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/command/job_dispatch.go b/command/job_dispatch.go index e49d495ec12..68e9863ab38 100644 --- a/command/job_dispatch.go +++ b/command/job_dispatch.go @@ -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 diff --git a/command/operator_debug.go b/command/operator_debug.go index b7980d769d5..1646f062d8f 100644 --- a/command/operator_debug.go +++ b/command/operator_debug.go @@ -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) @@ -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() @@ -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 }) }