4c1eda114d982ff5f7f7adc396f24c25d3f639d0

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #4216 from gkze/master

Add terraform completion

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..44e38a1c0b2761bbbad77bf4aa3a28ee0e9b0be6
  4--- /dev/null
  5+++ b/plugins/terraform/README.md
  6@@ -0,0 +1,11 @@
  7+## atom
  8+
  9+Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
 10+
 11+### Requirements
 12+
 13+ * [Terraform](https://terraform.io/)
 14+
 15+### Usage
 16+
 17+ * Type `terraform` into your prompt and hit `TAB` to see available completion options
 18diff --git a/plugins/terraform/_terraform b/plugins/terraform/_terraform
 19new file mode 100644
 20index 0000000000000000000000000000000000000000..11740dc4819cbda50cfb63dfda7ca14e16831f1d
 21--- /dev/null
 22+++ b/plugins/terraform/_terraform
 23@@ -0,0 +1,177 @@
 24+#compdef terraform
 25+
 26+local -a _terraform_cmds
 27+_terraform_cmds=(
 28+    'apply:Builds or changes infrastructure'
 29+    'destroy:Destroy Terraform-managed infrastructure'
 30+    'get:Download and install modules for the configuration'
 31+    'graph:Create a visual graph of Terraform resources'
 32+    'init:Initializes Terraform configuration from a module'
 33+    'output:Read an output from a state file'
 34+    'plan:Generate and show an execution plan'
 35+    'pull:Refreshes the local state copy from the remote server'
 36+    'push:Uploads the local state to the remote server'
 37+    'refresh:Update local state file against real resources'
 38+    'remote:Configures remote state management'
 39+    'show:Inspect Terraform state or plan'
 40+    'taint:Manually forcing a destroy and recreate on the next plan/apply'
 41+    'version:Prints the Terraform version'
 42+)
 43+
 44+__apply() {
 45+    _arguments \
 46+        '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
 47+        '-input=[(true) Ask for input for variables if not directly set.]' \
 48+        '-no-color[If specified, output will not contain any color.]' \
 49+        '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
 50+        '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
 51+        '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
 52+        '-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
 53+        '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
 54+        '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
 55+}
 56+
 57+__destroy() {
 58+    _arguments \
 59+        '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
 60+        '-force[If set, then the destroy confirmation will not be shown.]' \
 61+        '-input=[(true) Ask for input for variables if not directly set.]' \
 62+        '-no-color[If specified, output will not contain any color.]' \
 63+        '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
 64+        '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
 65+        '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
 66+        '-target=[(resource) Instead of affecting "dependencies" will instead also destroy any resources that depend on the target(s) specified.]' \
 67+        '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
 68+        '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
 69+}
 70+
 71+__get() {
 72+    _arguments \
 73+        '-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]'
 74+}
 75+
 76+__graph() {
 77+    _arguments \
 78+        '-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
 79+        '-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \
 80+        '-verbose[Generate a verbose, "worst-case" graph, with all nodes for potential operations in place.]'
 81+}
 82+
 83+__init() {
 84+    _arguments \
 85+        '-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \
 86+        '-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \
 87+        '-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \
 88+        '-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \
 89+        '-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]'
 90+}
 91+
 92+__output() {
 93+    _arguments \
 94+        '-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]' \
 95+        '-module=[(module_name) The module path which has needed output. By default this is the root path. Other modules can be specified by a period-separated list.]'
 96+}
 97+
 98+__plan() {
 99+    _arguments \
100+        '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with" .backup" extension. Set to "-" to disable backup.]' \
101+        '-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
102+        '-detailed-exitcode[Return a detailed exit code when the command exits. When provided, this argument changes the exit codes and their meanings to provide more granular information about what the resulting plan contains]' \
103+        '-input=[(true) Ask for input for variables if not directly set.]' \
104+        '-module-depth=[(n) Specifies the depth of modules to show in the output. This does not affect the plan itself, only the output shown. By default, this is zero. -1 will expand all.]' \
105+        '-no-color[If specified, output will not contain any color.]' \
106+        '-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
107+        '-refresh=[(true) Update state prior to checking for differences.]' \
108+        '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
109+        '-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
110+        '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
111+        '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
112+}
113+
114+__push() {
115+    _arguments \
116+        '-atlas-address=[(url) An alternate address to an Atlas instance. Defaults to https://atlas.hashicorp.com.]' \
117+        '-upload-modules=[(true) If true (default), then the modules being used are all locked at their current checkout and uploaded completely to Atlas. This prevents Atlas from running terraform get for you.]' \