From f376f7338c5a75bd66d71f32629eedce03fc1ea3 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Wed, 17 Jun 2020 09:12:20 -0400 Subject: [PATCH] cli: query all namespaces for alloc subcommands --- command/alloc_exec.go | 3 ++- command/alloc_fs.go | 3 ++- command/alloc_logs.go | 3 ++- command/alloc_restart.go | 3 ++- command/alloc_signal.go | 4 +++- command/alloc_status.go | 3 ++- command/alloc_stop.go | 5 ++++- 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/command/alloc_exec.go b/command/alloc_exec.go index c19bca29a..04b2dd45c 100644 --- a/command/alloc_exec.go +++ b/command/alloc_exec.go @@ -183,7 +183,8 @@ func (l *AllocExecCommand) Run(args []string) int { return 1 } // Prefix lookup matched a single allocation - alloc, _, err := client.Allocations().Info(allocs[0].ID, nil) + q := &api.QueryOptions{Namespace: allocs[0].Namespace} + alloc, _, err := client.Allocations().Info(allocs[0].ID, q) if err != nil { l.Ui.Error(fmt.Sprintf("Error querying allocation: %s", err)) return 1 diff --git a/command/alloc_fs.go b/command/alloc_fs.go index debbbb503..b7d5554d6 100644 --- a/command/alloc_fs.go +++ b/command/alloc_fs.go @@ -196,7 +196,8 @@ func (f *AllocFSCommand) Run(args []string) int { return 1 } // Prefix lookup matched a single allocation - alloc, _, err := client.Allocations().Info(allocs[0].ID, nil) + q := &api.QueryOptions{Namespace: allocs[0].Namespace} + alloc, _, err := client.Allocations().Info(allocs[0].ID, q) if err != nil { f.Ui.Error(fmt.Sprintf("Error querying allocation: %s", err)) return 1 diff --git a/command/alloc_logs.go b/command/alloc_logs.go index 5865f955b..6e916ca8e 100644 --- a/command/alloc_logs.go +++ b/command/alloc_logs.go @@ -171,7 +171,8 @@ func (l *AllocLogsCommand) Run(args []string) int { return 1 } // Prefix lookup matched a single allocation - alloc, _, err := client.Allocations().Info(allocs[0].ID, nil) + q := &api.QueryOptions{Namespace: allocs[0].Namespace} + alloc, _, err := client.Allocations().Info(allocs[0].ID, q) if err != nil { l.Ui.Error(fmt.Sprintf("Error querying allocation: %s", err)) return 1 diff --git a/command/alloc_restart.go b/command/alloc_restart.go index b27b0f363..bacd04efa 100644 --- a/command/alloc_restart.go +++ b/command/alloc_restart.go @@ -96,7 +96,8 @@ func (c *AllocRestartCommand) Run(args []string) int { } // Prefix lookup matched a single allocation - alloc, _, err := client.Allocations().Info(allocs[0].ID, nil) + q := &api.QueryOptions{Namespace: allocs[0].Namespace} + alloc, _, err := client.Allocations().Info(allocs[0].ID, q) if err != nil { c.Ui.Error(fmt.Sprintf("Error querying allocation: %s", err)) return 1 diff --git a/command/alloc_signal.go b/command/alloc_signal.go index bc33825a0..418108ef2 100644 --- a/command/alloc_signal.go +++ b/command/alloc_signal.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/api/contexts" "github.com/posener/complete" ) @@ -100,7 +101,8 @@ func (c *AllocSignalCommand) Run(args []string) int { } // Prefix lookup matched a single allocation - alloc, _, err := client.Allocations().Info(allocs[0].ID, nil) + q := &api.QueryOptions{Namespace: allocs[0].Namespace} + alloc, _, err := client.Allocations().Info(allocs[0].ID, q) if err != nil { c.Ui.Error(fmt.Sprintf("Error querying allocation: %s", err)) return 1 diff --git a/command/alloc_status.go b/command/alloc_status.go index 52e0faa41..c22d23e53 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -166,7 +166,8 @@ func (c *AllocStatusCommand) Run(args []string) int { return 0 } // Prefix lookup matched a single allocation - alloc, _, err := client.Allocations().Info(allocs[0].ID, nil) + q := &api.QueryOptions{Namespace: allocs[0].Namespace} + alloc, _, err := client.Allocations().Info(allocs[0].ID, q) if err != nil { c.Ui.Error(fmt.Sprintf("Error querying allocation: %s", err)) return 1 diff --git a/command/alloc_stop.go b/command/alloc_stop.go index a44842f69..37050b460 100644 --- a/command/alloc_stop.go +++ b/command/alloc_stop.go @@ -3,6 +3,8 @@ package command import ( "fmt" "strings" + + "github.com/hashicorp/nomad/api" ) type AllocStopCommand struct { @@ -102,7 +104,8 @@ func (c *AllocStopCommand) Run(args []string) int { } // Prefix lookup matched a single allocation - alloc, _, err := client.Allocations().Info(allocs[0].ID, nil) + q := &api.QueryOptions{Namespace: allocs[0].Namespace} + alloc, _, err := client.Allocations().Info(allocs[0].ID, q) if err != nil { c.Ui.Error(fmt.Sprintf("Error querying allocation: %s", err)) return 1