_nomad 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #compdef nomad
  2. local -a _nomad_cmds
  3. _nomad_cmds=(
  4. 'agent:Runs a Nomad agent'
  5. 'agent-info:Display status information about the local agent'
  6. 'alloc-status:Display allocation status information and metadata'
  7. 'client-config:View or modify client configuration details'
  8. 'eval-status:Display evaluation status and placement failure reasons'
  9. 'fs:Inspect the contents of an allocation directory'
  10. 'init:Create an example job file'
  11. 'inspect:Inspect a submitted job'
  12. 'logs:Streams the logs of a task.'
  13. 'node-drain:Toggle drain mode on a given node'
  14. 'node-status:Display status information about nodes'
  15. 'plan:Dry-run a job update to determine its effects'
  16. 'run:Run a new job or update an existing'
  17. 'server-force-leave:Force a server into the left state'
  18. 'server-join:Join server nodes together'
  19. 'server-members:Display a list of known servers and their'
  20. 'status:Display status information about jobs'
  21. 'stop:Stop a running job'
  22. 'validate:Checks if a given job specification is valid'
  23. 'version:Prints the Nomad version'
  24. )
  25. __allocstatus() {
  26. _arguments \
  27. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  28. '-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.]' \
  29. '-no-color[Disables colored command output.]' \
  30. '-short[Display short output. Shows only the most recent task event.]' \
  31. '-stats[Display detailed resource usage statistics.]' \
  32. '-verbose[Show full information.]' \
  33. '-json[Output the allocation in its JSON format.]' \
  34. '-t[Format and display allocation using a Go template.]'
  35. }
  36. __evalstatus() {
  37. _arguments \
  38. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  39. '-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.]' \
  40. '-no-color[Disables colored command output.]' \
  41. '-monitor[Monitor an outstanding evaluation.]' \
  42. '-verbose[Show full information.]' \
  43. '-json[Output the allocation in its JSON format.]' \
  44. '-t[Format and display allocation using a Go template.]'
  45. }
  46. __inspect() {
  47. _arguments \
  48. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  49. '-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.]' \
  50. '-no-color[Disables colored command output.]' \
  51. '-json[Output the allocation in its JSON format.]' \
  52. '-t[Format and display allocation using a Go template.]'
  53. }
  54. __logs() {
  55. _arguments \
  56. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  57. '-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.]' \
  58. '-no-color[Disables colored command output.]' \
  59. '-stderr[ Display stderr logs.]' \
  60. '-job[<job-id> Use a random allocation from the specified job ID.]' \
  61. '-verbose[Show full information.]' \
  62. '-f[Causes the output to not stop when the end of the logs are reached, but rather to wait for additional output.]' \
  63. '-tail[Show the logs contents with offsets relative to the end of the logs. If no offset is given, -n is defaulted to 10.]' \
  64. '-n[Sets the tail location in best-efforted number of lines relative to the end of the logs.]' \
  65. '-c[Sets the tail location in number of bytes relative to the end of the logs.]'
  66. }
  67. __nodestatus() {
  68. _arguments \
  69. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  70. '-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.]' \
  71. '-no-color[Disables colored command output.]' \
  72. '-self[Query the status of the local node.]' \
  73. '-allocs[ Display a count of running allocations for each node.]' \
  74. '-short[Display short output. Shows only the most recent task event.]' \
  75. '-stats[Display detailed resource usage statistics.]' \
  76. '-verbose[Show full information.]' \
  77. '-json[Output the allocation in its JSON format.]' \
  78. '-t[Format and display allocation using a Go template.]'
  79. }
  80. __plan() {
  81. _arguments \
  82. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  83. '-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.]' \
  84. '-no-color[Disables colored command output.]' \
  85. '-diff[Determines whether the diff between the remote job and planned job is shown. Defaults to true.]'
  86. }
  87. __run() {
  88. _arguments \
  89. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  90. '-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.]' \
  91. '-no-color[Disables colored command output.]' \
  92. '-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.]' \
  93. '-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.]' \
  94. '-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
  95. '-verbose[Show full information.]'
  96. }
  97. __status() {
  98. _arguments \
  99. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  100. '-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.]' \
  101. '-no-color[Disables colored command output.]' \
  102. '-short[Display short output. Shows only the most recent task event.]' \
  103. '-evals[Display the evaluations associated with the job.]' \
  104. '-verbose[Show full information.]'
  105. }
  106. __stop() {
  107. _arguments \
  108. '-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
  109. '-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.]' \
  110. '-no-color[Disables colored command output.]' \
  111. '-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.]' \
  112. '-yes[Automatic yes to prompts.]' \
  113. '-verbose[Show full information.]'
  114. }
  115. _arguments '*:: :->command'
  116. if (( CURRENT == 1 )); then
  117. _describe -t commands "nomad command" _nomad_cmds
  118. return
  119. fi
  120. local -a _command_args
  121. case "$words[1]" in
  122. alloc-status)
  123. __allocstatus ;;
  124. eval-status)
  125. __evalstatus ;;
  126. inspect)
  127. __inspect ;;
  128. logs)
  129. __logs ;;
  130. node-status)
  131. __nodestatus ;;
  132. plan)
  133. __plan ;;
  134. run)
  135. __run ;;
  136. status)
  137. __status ;;
  138. stop)
  139. __stop ;;
  140. esac