mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-08 04:34:00 +02:00
272 lines
15 KiB
Text
272 lines
15 KiB
Text
#compdef terraform
|
|
|
|
local -a _terraform_cmds
|
|
_terraform_cmds=(
|
|
'apply:Builds or changes infrastructure'
|
|
'console:Interactive console for Terraform interpolations'
|
|
'destroy:Destroy Terraform-managed infrastructure'
|
|
'debug:Debug output management (experimental)'
|
|
'env:Environment management'
|
|
'fmt:Rewrites config files to canonical format'
|
|
'force-unlock:Manually unlock the terraform state'
|
|
'get:Download and install modules for the configuration'
|
|
'graph:Create a visual graph of Terraform resources'
|
|
'import:Import existing infrastructure into Terraform'
|
|
'init:Initialize a new or existing Terraform configuration'
|
|
'output:Read an output from a state file'
|
|
'plan:Generate and show an execution plan'
|
|
'push:Upload this Terraform module to Atlas to run'
|
|
'refresh:Update local state file against real resources'
|
|
'show:Inspect Terraform state or plan'
|
|
'state:Advanced state management'
|
|
'taint:Manually forcing a destroy and recreate on the next plan/apply'
|
|
'untaint:Manually unmark a resource as tainted'
|
|
'validate:Validates the Terraform files'
|
|
'version:Prints the Terraform version'
|
|
)
|
|
|
|
__apply() {
|
|
_arguments \
|
|
'-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.]' \
|
|
'-lock=[(true) Lock the state file when locking is supported.]' \
|
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
'-parallelism=[(n) Limit the number of parallel resource operations. Defaults to 10.]' \
|
|
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
|
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
|
|
'-var [("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
'-var-file=[(foo) 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.]'
|
|
}
|
|
|
|
__console() {
|
|
_arguments \
|
|
' -state=[(path) Path to read state. Defaults to "terraform.tfstate"]' \
|
|
' -var [("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
' -var-file=[(foo) 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.]'
|
|
}
|
|
|
|
__debug() {
|
|
__arguments \
|
|
'json2dot[Convert json graph log to dot]'
|
|
|
|
}
|
|
|
|
__destroy() {
|
|
_arguments \
|
|
'-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.]' \
|
|
'-force [Dont ask for input for destroy confirmation.]' \
|
|
'-lock=[(true) Lock the state file when locking is supported.]' \
|
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
'-parallelism=[(n) Limit the number of concurrent operations. Defaults to 10.]' \
|
|
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
|
|
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
|
|
'-var [("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
'-var-file=[(foo) 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.]'
|
|
}
|
|
|
|
__env() {
|
|
__arguments \
|
|
'list[List environments.]' \
|
|
'select[Select an environment.]' \
|
|
'new[Create a new environment.]' \
|
|
'delete[Delete an existing environment.]'
|
|
}
|
|
|
|
__fmt() {
|
|
__arguments \
|
|
'-list=[(true) List files whose formatting differs (always false if using STDIN)]' \
|
|
'-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN)]' \
|
|
'-diff=[(false) Display diffs of formatting changes]'
|
|
}
|
|
|
|
__get() {
|
|
_arguments \
|
|
'-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \
|
|
'-no-color[If specified, output wont contain any color.]'
|
|
}
|
|
|
|
__graph() {
|
|
_arguments \
|
|
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
'-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]'
|
|
|
|
}
|
|
|
|
__import() {
|
|
_arguments \
|
|
'-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.'] \
|
|
'-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \
|
|
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
'-lock=[(true) Lock the state file when locking is supported.]' \
|
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
'-provider=[(provider) Specific provider to use for import. This is used for specifying aliases, such as "aws.eu". Defaults to the normal provider prefix of the resource being imported.]' \
|
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' \
|
|
'-var [("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
|
|
'-var-file=[(foo) 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.]'
|
|
}
|
|
|
|
__init() {
|
|
_arguments \
|
|
'-backend=[(true) Configure the backend for this environment.]' \
|
|
'-backend-config=[(path) This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a "key=value" format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \
|
|
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
|
|
'-get=[(true) Download any modules for this configuration.]' \
|
|
'-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \
|
|
'-lock=[(true) Lock the state file when locking is supported.]' \
|
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]'
|
|
}
|
|
|
|
__output() {
|
|
_arguments \
|
|
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".'] \
|
|
'-no-color[If specified, output wont contain any color.'] \
|
|
'-module=[(name) If specified, returns the outputs for a specific module'] \
|
|
'-json[If specified, machine readable output will be printed in JSON format']
|
|
}
|
|
|
|
__plan() {
|
|
_arguments \
|
|
'-destroy [If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
|
|
'-detailed-exitcode[Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored; 2 - Succeeded, there is a diff]' \
|
|
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
'-lock=[(true) Lock the state file when locking is supported.]' \
|
|
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
'-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 -1, which will expand all.]' \
|
|
'-no-color [If specified, output wont contain any color.]' \
|
|
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
|
|
'-parallelism=[(n) Limit the number of concurrent operations. Defaults to 10.]' \
|
|
'-refresh=[(true) Update state prior to checking for differences.]' \
|
|
'-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.]' \
|
|
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
|
|
'-var [("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
'-var-file=[(foo) 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.]'
|
|
}
|
|
|
|
__push() {
|
|
_arguments \
|
|
'-atlas-address=[(<url>) An alternate address to an Atlas instance. Defaults to https://atlas.hashicorp.com]' \
|
|
'-upload-modules=[(true) If true (default), then the modules are locked at their current checkout and uploaded completely. This prevents Atlas from running "terraform get".]' \
|
|
'-name=[(<name>) Name of the configuration in Atlas. This can also be set in the configuration itself. Format is typically: "username/name".]' \
|
|
'-token=[(<token>) Access token to use to upload. If blank or unspecified, the ATLAS_TOKEN environmental variable will be used.]' \
|
|
'-overwrite=[(foo) Variable keys that should overwrite values in Atlas. Otherwise, variables already set in Atlas will overwrite local values. This flag can be repeated.]' \
|
|
'-var [("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
'-var-file=[(foo) 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.]' \
|
|
'-vcs=[(true) If true (default), push will upload only files committed to your VCS, if detected.]' \
|
|
'-no-color[If specified, output wont contain any color.]'
|
|
}
|
|
|
|
__refresh() {
|
|
_arguments \
|
|
'-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.]' \
|
|
'-input=[(true)Ask for input for variables if not directly set.]' \
|
|
'-lock=[(true)Lock the state file when locking is supported.]' \
|
|
'-lock-timeout=[(0s)Duration to retry a state lock.]' \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
'-state=[(path)Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
|
'-state-out=[(path)Path to write updated state file. By default, the "-state" path will be used.]' \
|
|
'-target=[(resource)Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \
|
|
'-var [("foo=bar")Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
'-var-file=[(foo)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.]'
|
|
}
|
|
|
|
__remote() {
|
|
_arguments \
|
|
'-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \
|
|
'-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \
|
|
'-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \
|
|
'-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.]' \
|
|
'-disable[Disables remote state management and migrates the state to the -state path.]' \
|
|
'-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \
|
|
'-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]' \
|
|
'-pull=[(true) Controls if the remote state is pulled before disabling. This defaults to true to ensure the latest state is cached before disabling.]' \
|
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]'
|
|
}
|
|
|
|
__show() {
|
|
_arguments \
|
|
'-module-depth=[(n) The maximum depth to expand modules. By default this is zero, which will not expand modules at all.]' \
|
|
'-no-color[If specified, output will not contain any color.]'
|
|
}
|
|
|
|
__taint() {
|
|
_arguments \
|
|
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
|
'-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.]' \
|
|
'-lock=[(true) Lock the state file when locking is supported.]' \
|
|
'-lock-timeout=[(0s ) Duration to retry a state lock.]' \
|
|
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
|
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]'
|
|
}
|
|
|
|
__validate() {
|
|
__arguments \
|
|
'-no-color[If specified, output wont contain any color.]' \
|
|
}
|
|
|
|
__version() {}
|
|
|
|
_arguments '*:: :->command'
|
|
|
|
if (( CURRENT == 1 )); then
|
|
_describe -t commands "terraform command" _terraform_cmds
|
|
return
|
|
fi
|
|
|
|
local -a _command_args
|
|
case "$words[1]" in
|
|
apply)
|
|
__apply ;;
|
|
console)
|
|
__console ;;
|
|
debug)
|
|
__debug ;;
|
|
destroy)
|
|
__destroy ;;
|
|
env)
|
|
__env ;;
|
|
fmt)
|
|
__fmt ;;
|
|
force-unlock)
|
|
__force-unlock ;;
|
|
get)
|
|
__get ;;
|
|
graph)
|
|
__graph ;;
|
|
import)
|
|
__import ;;
|
|
init)
|
|
__init ;;
|
|
output)
|
|
__output ;;
|
|
plan)
|
|
__plan ;;
|
|
push)
|
|
__push ;;
|
|
refresh)
|
|
__refresh ;;
|
|
show)
|
|
__show ;;
|
|
state)
|
|
__state ;;
|
|
taint)
|
|
__taint ;;
|
|
untaint)
|
|
__untaint ;;
|
|
validate)
|
|
__validate ;;
|
|
version)
|
|
__version ;;
|
|
esac
|