Class: RubyTerraform::Commands::Format
- Includes:
- Options::Global
- Defined in:
- lib/ruby_terraform/commands/format.rb
Overview
Wraps the terraform fmt command which rewrites all terraform configuration files to a canonical format.
Both configuration files (.tf) and variables files (.tfvars) are updated. JSON files (.tf.json or .tfvars.json) are not modified.
If :directory
is not specified in the parameters map then the current working directory will be used. If :directory
is “-” then content will be read from the standard input. The given content must be in the terraform language native syntax; JSON is not supported.
For options accepted on construction, see Base#initialize.
When executing an instance of Format via Base#execute, the following options are supported:
-
:directory
: the path to a directory containing terraform configuration (deprecated in terraform 0.14, removed in terraform 0.15, use:chdir
instead). -
:chdir
: the path of a working directory to switch to before executing the given subcommand. -
:list
: Iftrue
, lists files whose formatting differs; defaults tofalse
; always disabled if using standard input. -
:write
: Iftrue
, writes to source files; defaults tofalse
; always disabled if using standard input or:check
istrue
. -
:diff
: Iftrue
, displays diffs of formatting changes; defaults tofalse
. -
:check
: Iftrue
, checks if the input is formatted; if any input is not properly formatted, an Errors::ExecutionError will be thrown; defaults tofalse
. -
:no_color
: whether or not the output from the command should be in color; defaults tofalse
. -
:recursive
: Iftrue
, also processes files in subdirectories; defaults tofalse
such that only the provided:directory
is processed.
The Base#execute method accepts an optional second parameter which is a map of invocation options. Currently, the only supported option is :environment
which is a map of environment variables to expose during invocation of the command.
Constructor Details
This class inherits a constructor from RubyTerraform::Commands::Base