mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Add -group flag to alloc exec, alloc logs command (#25568)
* Add -group flag to `alloc exec`, `alloc logs` command * fixup! Add -group flag to `alloc exec`, `alloc logs` command * Add -group option to alloc fs * Add changelog
This commit is contained in:
3
.changelog/25568.txt
Normal file
3
.changelog/25568.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:improvement
|
||||
cli: Add -group option to `alloc exec`, `alloc logs`, `alloc fs` commands
|
||||
```
|
||||
@@ -53,6 +53,9 @@ Exec Specific Options:
|
||||
-job
|
||||
Use a random allocation from the specified job ID or prefix.
|
||||
|
||||
-group <group-name>
|
||||
Specifies the task group with the task when a random allocation is selected.
|
||||
|
||||
-i
|
||||
Pass stdin to the container, defaults to true. Pass -i=false to disable.
|
||||
|
||||
@@ -78,6 +81,7 @@ func (l *AllocExecCommand) AutocompleteFlags() complete.Flags {
|
||||
complete.Flags{
|
||||
"--task": complete.PredictAnything,
|
||||
"-job": complete.PredictAnything,
|
||||
"-group": complete.PredictAnything,
|
||||
"-i": complete.PredictNothing,
|
||||
"-t": complete.PredictNothing,
|
||||
"-e": complete.PredictSet("none", "~"),
|
||||
@@ -103,7 +107,7 @@ func (l *AllocExecCommand) Name() string { return "alloc exec" }
|
||||
|
||||
func (l *AllocExecCommand) Run(args []string) int {
|
||||
var job, stdinOpt, ttyOpt bool
|
||||
var task, escapeChar string
|
||||
var task, group, escapeChar string
|
||||
|
||||
flags := l.Meta.FlagSet(l.Name(), FlagSetClient)
|
||||
flags.Usage = func() { l.Ui.Output(l.Help()) }
|
||||
@@ -112,6 +116,7 @@ func (l *AllocExecCommand) Run(args []string) int {
|
||||
flags.BoolVar(&ttyOpt, "t", isTty(), "")
|
||||
flags.StringVar(&escapeChar, "e", "~", "")
|
||||
flags.StringVar(&task, "task", "", "")
|
||||
flags.StringVar(&group, "group", "", "")
|
||||
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@@ -168,7 +173,7 @@ func (l *AllocExecCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
allocStub, err = getRandomJobAlloc(client, jobID, "", ns)
|
||||
allocStub, err = getRandomJobAlloc(client, jobID, group, ns)
|
||||
if err != nil {
|
||||
l.Ui.Error(fmt.Sprintf("Error fetching allocations: %v", err))
|
||||
return 1
|
||||
|
||||
@@ -61,6 +61,9 @@ FS Specific Options:
|
||||
-job <job-id>
|
||||
Use a random allocation from the specified job ID or prefix.
|
||||
|
||||
-group <group-name>
|
||||
Specifies the task group with the task when a random allocation is selected.
|
||||
|
||||
-stat
|
||||
Show file stat information instead of displaying the file, or listing the directory.
|
||||
|
||||
@@ -92,6 +95,7 @@ func (f *AllocFSCommand) AutocompleteFlags() complete.Flags {
|
||||
"-H": complete.PredictNothing,
|
||||
"-verbose": complete.PredictNothing,
|
||||
"-job": complete.PredictAnything,
|
||||
"-group": complete.PredictAnything,
|
||||
"-stat": complete.PredictNothing,
|
||||
"-f": complete.PredictNothing,
|
||||
"-tail": complete.PredictNothing,
|
||||
@@ -120,12 +124,14 @@ func (f *AllocFSCommand) Name() string { return "alloc fs" }
|
||||
func (f *AllocFSCommand) Run(args []string) int {
|
||||
var verbose, machine, job, stat, tail, follow bool
|
||||
var numLines, numBytes int64
|
||||
var group string
|
||||
|
||||
flags := f.Meta.FlagSet(f.Name(), FlagSetClient)
|
||||
flags.Usage = func() { f.Ui.Output(f.Help()) }
|
||||
flags.BoolVar(&verbose, "verbose", false, "")
|
||||
flags.BoolVar(&machine, "H", false, "")
|
||||
flags.BoolVar(&job, "job", false, "")
|
||||
flags.StringVar(&group, "group", "", "")
|
||||
flags.BoolVar(&stat, "stat", false, "")
|
||||
flags.BoolVar(&follow, "f", false, "")
|
||||
flags.BoolVar(&tail, "tail", false, "")
|
||||
@@ -173,7 +179,7 @@ func (f *AllocFSCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
allocID, err = getRandomJobAllocID(client, jobID, "", ns)
|
||||
allocID, err = getRandomJobAllocID(client, jobID, group, ns)
|
||||
if err != nil {
|
||||
f.Ui.Error(fmt.Sprintf("Error fetching allocations: %v", err))
|
||||
return 1
|
||||
|
||||
@@ -26,7 +26,7 @@ type AllocLogsCommand struct {
|
||||
verbose, job, tail, stderr, stdout, follow bool
|
||||
numLines int64
|
||||
numBytes int64
|
||||
task string
|
||||
task, group string
|
||||
}
|
||||
|
||||
func (l *AllocLogsCommand) Help() string {
|
||||
@@ -60,6 +60,9 @@ Logs Specific Options:
|
||||
Sets the task to view the logs. If task name is given with both an argument
|
||||
and the '-task' option, preference is given to the '-task' option.
|
||||
|
||||
-group <group-name>
|
||||
Specifies the task group with the task when a random allocation is selected.
|
||||
|
||||
-job <job-id>
|
||||
Use a random allocation from the specified job ID or prefix.
|
||||
|
||||
@@ -100,6 +103,7 @@ func (l *AllocLogsCommand) AutocompleteFlags() complete.Flags {
|
||||
"-verbose": complete.PredictNothing,
|
||||
"-task": complete.PredictAnything,
|
||||
"-job": complete.PredictAnything,
|
||||
"-group": complete.PredictAnything,
|
||||
"-f": complete.PredictNothing,
|
||||
"-tail": complete.PredictAnything,
|
||||
"-n": complete.PredictAnything,
|
||||
@@ -137,6 +141,7 @@ func (l *AllocLogsCommand) Run(args []string) int {
|
||||
flags.Int64Var(&l.numLines, "n", -1, "")
|
||||
flags.Int64Var(&l.numBytes, "c", -1, "")
|
||||
flags.StringVar(&l.task, "task", "", "")
|
||||
flags.StringVar(&l.group, "group", "", "")
|
||||
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@@ -173,7 +178,7 @@ func (l *AllocLogsCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
allocID, err = getRandomJobAllocID(client, jobID, "", ns)
|
||||
allocID, err = getRandomJobAllocID(client, jobID, l.group, ns)
|
||||
if err != nil {
|
||||
l.Ui.Error(fmt.Sprintf("Error fetching allocations: %v", err))
|
||||
return 1
|
||||
|
||||
@@ -39,10 +39,13 @@ capabilities for the allocation's namespace.
|
||||
|
||||
## Exec options
|
||||
|
||||
- `-task`: Sets the task to exec command in.
|
||||
- `-task=<task-name>`: Sets the task to exec command in.
|
||||
|
||||
- `-job`: Use a random allocation from the specified job or job ID prefix,
|
||||
preferring a running allocation.
|
||||
- `-job=<job-name|job-id>`: Use a random allocation from the specified job or
|
||||
job ID prefix, preferring a running allocation.
|
||||
|
||||
- `-group=<group-name>`: Specifies the task group where the task is located
|
||||
when a random allocation is selected
|
||||
|
||||
- `-i`: Pass stdin to the container, defaults to true. Pass `-i=false` to
|
||||
disable explicitly.
|
||||
|
||||
@@ -48,8 +48,11 @@ When ACLs are enabled, this command requires a token with the `read-fs`,
|
||||
|
||||
- `-verbose`: Display verbose output.
|
||||
|
||||
- `-job`: Use a random allocation from the specified job or job ID prefix,
|
||||
preferring a running allocation.
|
||||
- `-job=<job-name|job-id>`: Use a random allocation from the specified job or
|
||||
job ID prefix, preferring a running allocation.
|
||||
|
||||
- `-group=<group-name>`: Specifies the task group where the task is located
|
||||
when a random allocation is selected
|
||||
|
||||
- `-stat`: Show stat information instead of displaying the file, or listing the
|
||||
directory.
|
||||
|
||||
@@ -43,10 +43,13 @@ When ACLs are enabled, this command requires a token with the `read-logs`,
|
||||
|
||||
- `-verbose`: Display verbose output.
|
||||
|
||||
- `-job`: Use a random allocation from the specified job or job ID prefix,
|
||||
preferring a running allocation.
|
||||
- `-job=<job-name|job-id>`: Use a random allocation from the specified job or
|
||||
job ID prefix, preferring a running allocation.
|
||||
|
||||
- `-task`: Specify the task to view the logs.
|
||||
- `-task=<task-name>`: Specify the task to view the logs.
|
||||
|
||||
- `-group=<group-name>`: Specifies the task group where the task is located
|
||||
when a random allocation is selected
|
||||
|
||||
- `-f`: Causes the output to not stop when the end of the logs are reached, but
|
||||
rather to wait for additional output. When supplied with no other flags except
|
||||
|
||||
Reference in New Issue
Block a user