From 6b7003c3efcabe5ce185d5c2a1a8b708d92dfb82 Mon Sep 17 00:00:00 2001 From: Laurent Commarieu Date: Mon, 26 Sep 2016 15:26:38 +0200 Subject: feat(plugin): add nomad --- plugins/nomad/README.md | 11 +++++++++++ plugins/nomad/_nomad | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 plugins/nomad/README.md create mode 100644 plugins/nomad/_nomad (limited to 'plugins/nomad') diff --git a/plugins/nomad/README.md b/plugins/nomad/README.md new file mode 100644 index 000000000..ff07e917b --- /dev/null +++ b/plugins/nomad/README.md @@ -0,0 +1,11 @@ +## About + +Plugin for Nomad, a tool from Hashicorp for easily deploy applications at any scale. + +### Requirements + + * [Nomad](https://nomadproject.io/) + +### Usage + + * Type `nomad` into your prompt and hit `TAB` to see available completion options diff --git a/plugins/nomad/_nomad b/plugins/nomad/_nomad new file mode 100644 index 000000000..25169f394 --- /dev/null +++ b/plugins/nomad/_nomad @@ -0,0 +1,51 @@ +#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.]' +} + +_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 ;; +esac -- cgit v1.2.3-70-g09d2 From dfd7bf9f4141fe6d2ec9cd067b01ad9920e80a24 Mon Sep 17 00:00:00 2001 From: Laurent Commarieu Date: Mon, 3 Oct 2016 21:11:54 +0200 Subject: feat(nomad): add common commands and new readme --- plugins/nomad/README.md | 16 +++++--- plugins/nomad/_nomad | 104 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 7 deletions(-) (limited to 'plugins/nomad') diff --git a/plugins/nomad/README.md b/plugins/nomad/README.md index ff07e917b..04b361683 100644 --- a/plugins/nomad/README.md +++ b/plugins/nomad/README.md @@ -1,11 +1,15 @@ -## About +# Nomad -Plugin for Nomad, a tool from Hashicorp for easily deploy applications at any scale. +The `nomad` plugin provides a simple autocompletion for [Nomad](https://nomadproject.io/), a tool from Hashicorp for easily deploy applications at any scale. -### Requirements +## Usage - * [Nomad](https://nomadproject.io/) +1. Enable the `nomad` plugin: -### Usage + ```zsh + plugins=(... nomad) + ``` - * Type `nomad` into your prompt and hit `TAB` to see available completion options +2. Install [Nomad](https://nomadproject.io/) + +3. Type `nomad` into your prompt and hit `TAB` to see available completion options. diff --git a/plugins/nomad/_nomad b/plugins/nomad/_nomad index 25169f394..1c935a02e 100644 --- a/plugins/nomad/_nomad +++ b/plugins/nomad/_nomad @@ -24,7 +24,6 @@ _nomad_cmds=( '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]' \ @@ -37,6 +36,93 @@ __allocstatus() { '-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[ 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 @@ -48,4 +134,20 @@ 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 -- cgit v1.2.3-70-g09d2