Check for errors initializing client for autocomplete
This commit is contained in:
parent
602cce5c21
commit
93add81844
|
@ -72,7 +72,11 @@ func (c *AllocStatusCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *AllocStatusCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Allocs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -52,7 +52,11 @@ func (c *DeploymentFailCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *DeploymentFailCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Deployments, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -44,7 +44,11 @@ func (c *DeploymentPauseCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *DeploymentPauseCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Deployments, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -62,7 +62,11 @@ func (c *DeploymentPromoteCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *DeploymentPromoteCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Deployments, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -50,7 +50,11 @@ func (c *DeploymentResumeCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *DeploymentResumeCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Deployments, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -53,7 +53,11 @@ func (c *DeploymentStatusCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *DeploymentStatusCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Deployments, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -60,7 +60,15 @@ func (c *EvalStatusCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *EvalStatusCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Evals, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -95,7 +95,11 @@ func (c *FSCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (f *FSCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := f.Meta.Client()
|
||||
client, err := f.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Allocs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -52,7 +52,11 @@ func (c *InspectCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *InspectCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -55,7 +55,11 @@ func (c *JobDeploymentsCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *JobDeploymentsCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -67,7 +67,11 @@ func (c *JobDispatchCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *JobDispatchCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -67,7 +67,11 @@ func (c *JobHistoryCommand) Autocompleteflags() complete.Flags {
|
|||
|
||||
func (c *JobHistoryCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -63,7 +63,11 @@ func (c *JobPromoteCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *JobPromoteCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -50,7 +50,11 @@ func (c *JobRevertCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *JobRevertCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -72,7 +72,11 @@ func (c *JobStatusCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *JobStatusCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -76,7 +76,11 @@ func (c *LogsCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (l *LogsCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := l.Meta.Client()
|
||||
client, err := l.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Allocs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -57,7 +57,11 @@ func (c *NodeDrainCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *NodeDrainCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Nodes, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -100,7 +100,11 @@ func (c *NodeStatusCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *NodeStatusCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Nodes, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -38,7 +38,11 @@ func (c *StatusCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *StatusCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.All, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
|
@ -63,7 +63,11 @@ func (c *StopCommand) AutocompleteFlags() complete.Flags {
|
|||
|
||||
func (c *StopCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
client, _ := c.Meta.Client()
|
||||
client, err := c.Meta.Client()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Jobs, nil)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
|
|
Loading…
Reference in New Issue