summaryrefslogtreecommitdiff
path: root/plugins/nomad/_nomad
blob: 1c935a02eac939ab3bfc6c564d9b63c8f2e150ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#compdef nomad

local -a _nomad_cmds
_nomad_cmds=(
  'agent:Runs a Nomad agent'
  'agent-info:Display status information about the local agent'
  'alloc-status:Display allocation status information and metadata'
  'client-config:View or modify client configuration details'
  'eval-status:Display evaluation status and placement failure reasons'
  'fs:Inspect the contents of an allocation directory'
  'init:Create an example job file'
  'inspect:Inspect a submitted job'
  'logs:Streams the logs of a task.'
  'node-drain:Toggle drain mode on a given node'
  'node-status:Display status information about nodes'
  'plan:Dry-run a job update to determine its effects'
  'run:Run a new job or update an existing'
  'server-force-leave:Force a server into the left state'
  'server-join:Join server nodes together'
  'server-members:Display a list of known servers and their'
  'status:Display status information about jobs'
  'stop:Stop a running job'
  'validate:Checks if a given job specification is valid'
  'version:Prints the Nomad version'
)

__allocstatus() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-short[Display short output. Shows only the most recent task event.]' \
    '-stats[Display detailed resource usage statistics.]' \
    '-verbose[Show full information.]' \
    '-json[Output the allocation in its JSON format.]' \
    '-t[Format and display allocation using a Go template.]'
}

__evalstatus() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-monitor[Monitor an outstanding evaluation.]' \
    '-verbose[Show full information.]' \
    '-json[Output the allocation in its JSON format.]' \
    '-t[Format and display allocation using a Go template.]'
}

__inspect() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-json[Output the allocation in its JSON format.]' \
    '-t[Format and display allocation using a Go template.]'
}

__logs() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-stderr[ Display stderr logs.]' \
    '-job[<job-id> Use a random allocation from the specified job ID.]' \
    '-verbose[Show full information.]' \
    '-f[Causes the output to not stop when the end of the logs are reached, but rather to wait for additional output.]' \
    '-tail[Show the logs contents with offsets relative to the end of the logs. If no offset is given, -n is defaulted to 10.]' \
    '-n[Sets the tail location in best-efforted number of lines relative to the end of the logs.]' \
    '-c[Sets the tail location in number of bytes relative to the end of the logs.]'
}

__nodestatus() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-self[Query the status of the local node.]' \
    '-allocs[ Display a count of running allocations for each node.]' \
    '-short[Display short output. Shows only the most recent task event.]' \
    '-stats[Display detailed resource usage statistics.]' \
    '-verbose[Show full information.]' \
    '-json[Output the allocation in its JSON format.]' \
    '-t[Format and display allocation using a Go template.]'
}

__plan() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]' 
}

__run() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-check-index[If set, the job is only registered or updated if the the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \
    '-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
    '-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
    '-verbose[Show full information.]'
}

__status() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-short[Display short output. Shows only the most recent task event.]' \
    '-evals[Display the evaluations associated with the job.]' \
    '-verbose[Show full information.]'
}

__stop() {
  _arguments \
    '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
    '-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
    '-no-color[Disables colored command output.]' \
    '-detach[Return immediately instead of entering monitor mode. After the deregister command is submitted, a new evaluation ID is printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
    '-yes[Automatic yes to prompts.]' \
    '-verbose[Show full information.]'
}

_arguments '*:: :->command'

if (( CURRENT == 1 )); then
  _describe -t commands "nomad command" _nomad_cmds
  return
fi

local -a _command_args
case "$words[1]" in
  alloc-status)
    __allocstatus ;;
  eval-status)
    __evalstatus ;;
  inspect)
    __inspect ;;
  logs)
    __logs ;;
  node-status)
    __nodestatus ;;
  plan)
    __plan ;;
  run)
    __run ;;
  status)
    __status ;;
  stop)
    __stop ;;
esac