ruby-terraform 0.65.0.pre.10 → 0.65.0.pre.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +18 -10
- data/README.md +2 -19
- data/lib/ruby_terraform.rb +691 -18
- data/lib/ruby_terraform/commands/apply.rb +75 -1
- data/lib/ruby_terraform/commands/base.rb +18 -15
- data/lib/ruby_terraform/commands/destroy.rb +67 -1
- data/lib/ruby_terraform/commands/force_unlock.rb +28 -0
- data/lib/ruby_terraform/commands/format.rb +39 -0
- data/lib/ruby_terraform/commands/get.rb +31 -0
- data/lib/ruby_terraform/commands/graph.rb +38 -0
- data/lib/ruby_terraform/commands/import.rb +95 -1
- data/lib/ruby_terraform/commands/init.rb +72 -1
- data/lib/ruby_terraform/commands/login.rb +24 -0
- data/lib/ruby_terraform/commands/logout.rb +21 -0
- data/lib/ruby_terraform/commands/output.rb +34 -4
- data/lib/ruby_terraform/commands/plan.rb +67 -1
- data/lib/ruby_terraform/commands/providers.rb +22 -0
- data/lib/ruby_terraform/commands/providers_lock.rb +66 -0
- data/lib/ruby_terraform/commands/providers_mirror.rb +42 -0
- data/lib/ruby_terraform/commands/taint.rb +2 -1
- data/lib/ruby_terraform/options.rb +25 -3
- data/lib/ruby_terraform/options/common.rb +1 -0
- data/lib/ruby_terraform/options/definition.rb +172 -0
- data/lib/ruby_terraform/options/definitions.rb +103 -0
- data/lib/ruby_terraform/options/factory.rb +10 -102
- data/lib/ruby_terraform/options/name.rb +11 -19
- data/lib/ruby_terraform/options/types.rb +27 -0
- data/lib/ruby_terraform/options/types/base.rb +6 -13
- data/lib/ruby_terraform/options/types/flag.rb +1 -3
- data/lib/ruby_terraform/options/types/standard.rb +1 -27
- data/lib/ruby_terraform/options/values.rb +38 -0
- data/lib/ruby_terraform/options/values/base.rb +15 -0
- data/lib/ruby_terraform/options/values/boolean.rb +13 -11
- data/lib/ruby_terraform/options/values/complex.rb +19 -0
- data/lib/ruby_terraform/options/values/key_value.rb +21 -0
- data/lib/ruby_terraform/options/values/string.rb +17 -0
- data/lib/ruby_terraform/version.rb +1 -1
- data/ruby_terraform.gemspec +3 -1
- metadata +40 -5
- data/lib/ruby_terraform/options/types/boolean.rb +0 -18
@@ -5,14 +5,83 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform apply+ command which creates or updates
|
9
|
+
# infrastructure according to terraform configuration files in the provided
|
10
|
+
# directory.
|
11
|
+
#
|
12
|
+
# By default, terraform will generate a new plan and present it for approval
|
13
|
+
# before taking any action. Alternatively, the command accepts a plan file
|
14
|
+
# created by a previous invocation, in which case terraform will take the
|
15
|
+
# actions described in that plan without any confirmation prompt.
|
16
|
+
#
|
17
|
+
# For options accepted on construction, see {#initialize}.
|
18
|
+
#
|
19
|
+
# When executing an instance of {Apply} via {#execute}, the following
|
20
|
+
# options are supported:
|
21
|
+
#
|
22
|
+
# * +:directory+: the directory containing terraform configuration;
|
23
|
+
# required unless +:plan+ is provided.
|
24
|
+
# * +:plan+: the path to a pre-computed plan to be applied;
|
25
|
+
# required unless +:directory+ is provided.
|
26
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
27
|
+
# the given subcommand.
|
28
|
+
# * +:auto_approve+: if +true+, skips interactive approval of the generated
|
29
|
+
# plan before applying; defaults to +false+.
|
30
|
+
# * +:backup+: the path to backup the existing state file before modifying;
|
31
|
+
# defaults to the +:state_out+ path with +".backup"+ extension; set
|
32
|
+
# +:no_backup+ to +true+ to skip backups entirely.
|
33
|
+
# * +:compact_warnings+: when +true+, if terraform produces any warnings
|
34
|
+
# that are not accompanied by errors, they are shown in a more compact
|
35
|
+
# form that includes only the summary messages; defaults to +false+.
|
36
|
+
# * +:input+: when +false+, will not ask for input for variables not
|
37
|
+
# directly set; defaults to +true+.
|
38
|
+
# * +:lock+: when +true+, locks the state file when locking is supported;
|
39
|
+
# when +false+, does not lock the state file; defaults to +true+.
|
40
|
+
# * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
|
41
|
+
# * +:no_backup+: when +true+, no backup file will be written; defaults to
|
42
|
+
# +false+.
|
43
|
+
# * +:no_color+: whether or not the output from the command should be in
|
44
|
+
# color; defaults to +false+.
|
45
|
+
# * +:parallelism+: the number of parallel resource operations; defaults to
|
46
|
+
# +10+.
|
47
|
+
# * +:refresh+: when +true+, updates state prior to checking for
|
48
|
+
# differences; when +false+ uses locally available state; defaults to
|
49
|
+
# +true+; this has no effect when +:plan+ is provided.
|
50
|
+
# * +:state+: the path to the state file from which to read state and in
|
51
|
+
# which to store state (unless +:state_out+ is specified); defaults to
|
52
|
+
# +"terraform.tfstate"+.
|
53
|
+
# * +:state_out+: the path to write state to that is different than
|
54
|
+
# +:state+; this can be used to preserve the old state.
|
55
|
+
# * +:target+: the address of a resource to target; if both +:target+ and
|
56
|
+
# +:targets+ are provided, all targets will be passed to terraform.
|
57
|
+
# * +:targets+: an array of resource addresses to target; if both +:target+
|
58
|
+
# and +:targets+ are provided, all targets will be passed to terraform.
|
59
|
+
# * +:vars+: a map of variables to be passed to the terraform configuration.
|
60
|
+
# * +:var_file+: the path to a terraform var file; if both +:var_file+ and
|
61
|
+
# +:var_files+ are provided, all var files will be passed to terraform.
|
62
|
+
# * +:var_files+: an array of paths to terraform var files; if both
|
63
|
+
# +:var_file+ and +:var_files+ are provided, all var files will be passed
|
64
|
+
# to terraform.
|
65
|
+
#
|
66
|
+
# @example Basic Invocation
|
67
|
+
# RubyTerraform::Commands::Apply.new.execute(
|
68
|
+
# directory: 'infra/networking',
|
69
|
+
# vars: {
|
70
|
+
# region: 'eu-central'
|
71
|
+
# })
|
72
|
+
#
|
8
73
|
class Apply < Base
|
9
74
|
include RubyTerraform::Options::Common
|
10
75
|
|
76
|
+
# @!visibility private
|
11
77
|
def subcommands
|
12
78
|
%w[apply]
|
13
79
|
end
|
14
80
|
|
15
|
-
|
81
|
+
# rubocop:disable Metrics/MethodLength
|
82
|
+
|
83
|
+
# @!visibility private
|
84
|
+
def options
|
16
85
|
%w[
|
17
86
|
-backup
|
18
87
|
-compact-warnings
|
@@ -31,14 +100,19 @@ module RubyTerraform
|
|
31
100
|
] + super
|
32
101
|
end
|
33
102
|
|
103
|
+
# rubocop:enable Metrics/MethodLength
|
104
|
+
|
105
|
+
# @!visibility private
|
34
106
|
def arguments(parameters)
|
35
107
|
[parameters[:plan] || parameters[:directory]]
|
36
108
|
end
|
37
109
|
|
110
|
+
# @!visibility private
|
38
111
|
def parameter_defaults(_parameters)
|
39
112
|
{ vars: {}, var_files: [], targets: [] }
|
40
113
|
end
|
41
114
|
|
115
|
+
# @!visibility private
|
42
116
|
def parameter_overrides(parameters)
|
43
117
|
{ backup: parameters[:no_backup] ? '-' : parameters[:backup] }
|
44
118
|
end
|
@@ -3,22 +3,27 @@
|
|
3
3
|
require 'lino'
|
4
4
|
|
5
5
|
require_relative '../errors'
|
6
|
-
require_relative '../options/factory'
|
7
6
|
|
8
7
|
module RubyTerraform
|
9
8
|
module Commands
|
10
9
|
class Base
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
|
10
|
+
# rubocop:disable Metrics/AbcSize
|
11
|
+
|
12
|
+
# Constructs an instance of the command.
|
13
|
+
#
|
14
|
+
def initialize(**opts)
|
15
|
+
@binary = opts[:binary] || RubyTerraform.configuration.binary
|
16
|
+
@logger = opts[:logger] || RubyTerraform.configuration.logger
|
17
|
+
@options = opts[:options] || RubyTerraform.configuration.options
|
18
|
+
@stdin = opts[:stdin] || RubyTerraform.configuration.stdin
|
19
|
+
@stdout = opts[:stdout] || RubyTerraform.configuration.stdout
|
20
|
+
@stderr = opts[:stderr] || RubyTerraform.configuration.stderr
|
20
21
|
end
|
21
22
|
|
23
|
+
# rubocop:enable Metrics/AbcSize
|
24
|
+
|
25
|
+
# Executes the command instance.
|
26
|
+
#
|
22
27
|
def execute(parameters = {})
|
23
28
|
do_before(parameters)
|
24
29
|
build_and_execute_command(parameters)
|
@@ -35,6 +40,7 @@ module RubyTerraform
|
|
35
40
|
|
36
41
|
def build_and_execute_command(parameters)
|
37
42
|
command = build_command(parameters)
|
43
|
+
|
38
44
|
logger.debug("Running '#{command}'.")
|
39
45
|
command.execute(
|
40
46
|
stdin: stdin,
|
@@ -53,8 +59,6 @@ module RubyTerraform
|
|
53
59
|
|
54
60
|
private
|
55
61
|
|
56
|
-
def initialize_command; end
|
57
|
-
|
58
62
|
def build_command(parameters)
|
59
63
|
parameters = resolve_parameters(parameters)
|
60
64
|
|
@@ -62,10 +66,9 @@ module RubyTerraform
|
|
62
66
|
.for_command(@binary)
|
63
67
|
.with_options_after_subcommands
|
64
68
|
.with_option_separator('=')
|
65
|
-
.with_appliables(
|
69
|
+
.with_appliables(@options.resolve(options, parameters))
|
66
70
|
.with_subcommands(subcommands)
|
67
|
-
.with_arguments(arguments(parameters))
|
68
|
-
.build
|
71
|
+
.with_arguments(arguments(parameters)).build
|
69
72
|
end
|
70
73
|
|
71
74
|
def resolve_parameters(parameters)
|
@@ -5,14 +5,75 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform destroy+ command which destroys terraform managed
|
9
|
+
# infrastructure.
|
10
|
+
#
|
11
|
+
# For options accepted on construction, see {#initialize}.
|
12
|
+
#
|
13
|
+
# When executing an instance of {Destroy} via {#execute}, the following
|
14
|
+
# options are supported:
|
15
|
+
#
|
16
|
+
# * +:directory+: the directory containing terraform configuration;
|
17
|
+
# required.
|
18
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
19
|
+
# the given subcommand.
|
20
|
+
# * +:auto_approve+: if +true+, skips interactive approval before
|
21
|
+
# destroying; defaults to +false+.
|
22
|
+
# * +:backup+: (legacy) the path to backup the existing state file before
|
23
|
+
# modifying; defaults to the +:state_out+ path with +".backup"+ extension;
|
24
|
+
# set +:no_backup+ to +true+ to skip backups entirely.
|
25
|
+
# * +:compact_warnings+: when +true+, if terraform produces any warnings
|
26
|
+
# that are not accompanied by errors, they are shown in a more compact
|
27
|
+
# form that includes only the summary messages; defaults to +false+.
|
28
|
+
# * +:input+: when +false+, will not ask for input for variables not
|
29
|
+
# directly set; defaults to +true+.
|
30
|
+
# * +:lock+: when +true+, locks the state file when locking is supported;
|
31
|
+
# when +false+, does not lock the state file; defaults to +true+.
|
32
|
+
# * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
|
33
|
+
# * +:no_backup+: when +true+, no backup file will be written; defaults to
|
34
|
+
# +false+.
|
35
|
+
# * +:no_color+: whether or not the output from the command should be in
|
36
|
+
# color; defaults to +false+.
|
37
|
+
# * +:parallelism+: the number of parallel resource operations; defaults to
|
38
|
+
# +10+.
|
39
|
+
# * +:refresh+: when +true+, updates state prior to checking for
|
40
|
+
# differences; when +false+ uses locally available state; defaults to
|
41
|
+
# +true+.
|
42
|
+
# * +:state+: (legacy) the path to the state file from which to read state
|
43
|
+
# and in which to store state (unless +:state_out+ is specified); defaults
|
44
|
+
# to +"terraform.tfstate"+.
|
45
|
+
# * +:state_out+: (legacy) the path to write state to that is different than
|
46
|
+
# +:state+; this can be used to preserve the old state.
|
47
|
+
# * +:target+: the address of a resource to target; if both +:target+ and
|
48
|
+
# +:targets+ are provided, all targets will be passed to terraform.
|
49
|
+
# * +:targets+: an array of resource addresses to target; if both +:target+
|
50
|
+
# and +:targets+ are provided, all targets will be passed to terraform.
|
51
|
+
# * +:vars+: a map of variables to be passed to the terraform configuration.
|
52
|
+
# * +:var_file+: the path to a terraform var file; if both +:var_file+ and
|
53
|
+
# +:var_files+ are provided, all var files will be passed to terraform.
|
54
|
+
# * +:var_files+: an array of paths to terraform var files; if both
|
55
|
+
# +:var_file+ and +:var_files+ are provided, all var files will be passed
|
56
|
+
# to terraform.
|
57
|
+
#
|
58
|
+
# @example Basic Invocation
|
59
|
+
# RubyTerraform::Commands::Destroy.new.execute(
|
60
|
+
# directory: 'infra/networking',
|
61
|
+
# vars: {
|
62
|
+
# region: 'eu-central'
|
63
|
+
# })
|
64
|
+
#
|
8
65
|
class Destroy < Base
|
9
66
|
include RubyTerraform::Options::Common
|
10
67
|
|
68
|
+
# @!visibility private
|
11
69
|
def subcommands
|
12
70
|
%w[destroy]
|
13
71
|
end
|
14
72
|
|
15
|
-
|
73
|
+
# rubocop:disable Metrics/MethodLength
|
74
|
+
|
75
|
+
# @!visibility private
|
76
|
+
def options
|
16
77
|
%w[
|
17
78
|
-backup
|
18
79
|
-compact-warnings
|
@@ -31,14 +92,19 @@ module RubyTerraform
|
|
31
92
|
] + super
|
32
93
|
end
|
33
94
|
|
95
|
+
# rubocop:enable Metrics/MethodLength
|
96
|
+
|
97
|
+
# @!visibility private
|
34
98
|
def arguments(parameters)
|
35
99
|
[parameters[:directory]]
|
36
100
|
end
|
37
101
|
|
102
|
+
# @!visibility private
|
38
103
|
def parameter_defaults(_parameters)
|
39
104
|
{ vars: {}, var_files: [], targets: [] }
|
40
105
|
end
|
41
106
|
|
107
|
+
# @!visibility private
|
42
108
|
def parameter_overrides(parameters)
|
43
109
|
{ backup: parameters[:no_backup] ? '-' : parameters[:backup] }
|
44
110
|
end
|
@@ -5,17 +5,45 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform force-unlock+ command which manually unlocks the
|
9
|
+
# state for the defined configuration.
|
10
|
+
#
|
11
|
+
# This will not modify your infrastructure. This command removes the lock on
|
12
|
+
# the state for the current workspace. The behavior of this lock is
|
13
|
+
# dependent on the backend being used. Local state files cannot be unlocked
|
14
|
+
# by another process.
|
15
|
+
#
|
16
|
+
# For options accepted on construction, see {#initialize}.
|
17
|
+
#
|
18
|
+
# When executing an instance of {ForceUnlock} via {#execute}, the following
|
19
|
+
# options are supported:
|
20
|
+
#
|
21
|
+
# * +:lock_id+: the lock ID output when attempting an operation that failed
|
22
|
+
# due to a lock; required.
|
23
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
24
|
+
# the given subcommand.
|
25
|
+
# * +:force+: If +true+, does not ask for input for unlock confirmation;
|
26
|
+
# defaults to +false+.
|
27
|
+
#
|
28
|
+
# @example Basic Invocation
|
29
|
+
# RubyTerraform::Commands::ForceUnlock.new.execute(
|
30
|
+
# lock_id: '50e844a7-ebb0-fcfd-da85-5cce5bd1ec90')
|
31
|
+
#
|
8
32
|
class ForceUnlock < Base
|
9
33
|
include RubyTerraform::Options::Common
|
10
34
|
|
35
|
+
# @!visibility private
|
11
36
|
def subcommands
|
12
37
|
%w[force-unlock]
|
13
38
|
end
|
14
39
|
|
40
|
+
# @!visibility private
|
15
41
|
def options
|
16
42
|
%w[-force] + super
|
17
43
|
end
|
18
44
|
|
45
|
+
# @!visibility private
|
46
|
+
# @todo Add directory option.
|
19
47
|
def arguments(parameters)
|
20
48
|
[parameters[:lock_id]]
|
21
49
|
end
|
@@ -5,13 +5,51 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform fmt+ command which rewrites all terraform
|
9
|
+
# configuration files to a canonical format.
|
10
|
+
#
|
11
|
+
# Both configuration files (.tf) and variables files (.tfvars) are updated.
|
12
|
+
# JSON files (.tf.json or .tfvars.json) are not modified.
|
13
|
+
#
|
14
|
+
# If +:directory+ is not specified in the parameters map then the current
|
15
|
+
# working directory will be used. If +:directory+ is +"-"+ then content will
|
16
|
+
# be read from the standard input. The given content must be in the
|
17
|
+
# terraform language native syntax; JSON is not supported.
|
18
|
+
#
|
19
|
+
# For options accepted on construction, see {#initialize}.
|
20
|
+
#
|
21
|
+
# When executing an instance of {Format} via {#execute}, the following
|
22
|
+
# options are supported:
|
23
|
+
#
|
24
|
+
# * +:directory+: the directory containing terraform configuration.
|
25
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
26
|
+
# the given subcommand.
|
27
|
+
# * +:list+: If +true+, lists files whose formatting differs; defaults to
|
28
|
+
# +false+; always disabled if using standard input.
|
29
|
+
# * +:write+: If +true+, writes to source files; defaults to +false+; always
|
30
|
+
# disabled if using standard input or +:check+ is +true+.
|
31
|
+
# * +:diff+: If +true+, displays diffs of formatting changes; defaults to
|
32
|
+
# +false+.
|
33
|
+
# * +:check+: If +true+, checks if the input is formatted; if any input is
|
34
|
+
# not properly formatted, an {RubyTerraform::Errors::ExecutionError} will
|
35
|
+
# be thrown; defaults to +false+.
|
36
|
+
# * +:recursive+: If +true+, also processes files in subdirectories;
|
37
|
+
# defaults to +false+ such that only the provided +:directory+ is
|
38
|
+
# processed.
|
39
|
+
#
|
40
|
+
# @example Basic Invocation
|
41
|
+
# RubyTerraform::Commands::Format.new.execute(
|
42
|
+
# directory: 'infra/networking')
|
8
43
|
class Format < Base
|
9
44
|
include RubyTerraform::Options::Common
|
10
45
|
|
46
|
+
# @!visibility private
|
11
47
|
def subcommands
|
12
48
|
%w[fmt]
|
13
49
|
end
|
14
50
|
|
51
|
+
# @!visibility private
|
52
|
+
# @todo Add no_color option.
|
15
53
|
def options
|
16
54
|
%w[
|
17
55
|
-list
|
@@ -22,6 +60,7 @@ module RubyTerraform
|
|
22
60
|
] + super
|
23
61
|
end
|
24
62
|
|
63
|
+
# @!visibility private
|
25
64
|
def arguments(parameters)
|
26
65
|
[parameters[:directory]]
|
27
66
|
end
|
@@ -5,13 +5,43 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform get+ command which downloads and installs modules
|
9
|
+
# needed for the given configuration.
|
10
|
+
#
|
11
|
+
# This recursively downloads all modules needed, such as modules imported by
|
12
|
+
# the root and so on. If a module is already downloaded, it will not be
|
13
|
+
# redownloaded or checked for updates unless +:update+ is +true+.
|
14
|
+
#
|
15
|
+
# Module installation also happens automatically by default as part of
|
16
|
+
# the {Init} command, so you should rarely need to run this
|
17
|
+
# command separately.
|
18
|
+
#
|
19
|
+
# For options accepted on construction, see {#initialize}.
|
20
|
+
#
|
21
|
+
# When executing an instance of {Get} via {#execute}, the following options
|
22
|
+
# are supported:
|
23
|
+
#
|
24
|
+
# * +:directory+: the directory containing terraform configuration;
|
25
|
+
# required.
|
26
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
27
|
+
# the given subcommand.
|
28
|
+
# * +:update+: if +true+, checks already-downloaded modules for available
|
29
|
+
# updates and installs the newest versions available; defaults to +false+.
|
30
|
+
# * +:no_color+: whether or not the output from the command should be in
|
31
|
+
# color; defaults to +false+.
|
32
|
+
#
|
33
|
+
# @example Basic Invocation
|
34
|
+
# RubyTerraform::Commands::Get.new.execute(
|
35
|
+
# directory: 'infra/networking')
|
8
36
|
class Get < Base
|
9
37
|
include RubyTerraform::Options::Common
|
10
38
|
|
39
|
+
# @!visibility private
|
11
40
|
def subcommands
|
12
41
|
%w[get]
|
13
42
|
end
|
14
43
|
|
44
|
+
# @!visibility private
|
15
45
|
def options
|
16
46
|
%w[
|
17
47
|
-no-color
|
@@ -19,6 +49,7 @@ module RubyTerraform
|
|
19
49
|
] + super
|
20
50
|
end
|
21
51
|
|
52
|
+
# @!visibility private
|
22
53
|
def arguments(parameters)
|
23
54
|
[parameters[:directory]]
|
24
55
|
end
|
@@ -5,13 +5,51 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform graph+ command which outputs the visual execution
|
9
|
+
# graph of terraform resources according to either the current configuration
|
10
|
+
# or an execution plan.
|
11
|
+
#
|
12
|
+
# The graph is outputted in DOT format. The typical program that can
|
13
|
+
# read this format is GraphViz, but many web services are also available to
|
14
|
+
# read this format.
|
15
|
+
#
|
16
|
+
# The +:type+ option can be used to control the type of graph shown.
|
17
|
+
# Terraform creates different graphs for different operations. See the
|
18
|
+
# options below for the list of types supported. The default type is
|
19
|
+
# +"plan"+ if a configuration is given, and +"apply"+ if a plan file is
|
20
|
+
# passed as an argument.
|
21
|
+
#
|
22
|
+
# For options accepted on construction, see {#initialize}.
|
23
|
+
#
|
24
|
+
# When executing an instance of {Graph} via {#execute}, the following
|
25
|
+
# options are supported:
|
26
|
+
#
|
27
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
28
|
+
# the given subcommand.
|
29
|
+
# * +:plan+: render the graph using the specified plan file instead of the
|
30
|
+
# configuration in the current directory.
|
31
|
+
# * +:draw_cycles+: if +true+, highlights any cycles in the graph with
|
32
|
+
# colored edges; this helps when diagnosing cycle errors; defaults to
|
33
|
+
# +false+.
|
34
|
+
# * +:type+: the type of graph to output; can be: +"plan"+,
|
35
|
+
# +"plan-destroy"+, +"apply"+, +"validate"+, +"input"+, +"refresh"+;
|
36
|
+
# defaults to +"apply"+ if +:plan+ is provided, +"plan"+ otherwise.
|
37
|
+
# * +:module_depth+: (deprecated) in prior versions of terraform, specified
|
38
|
+
# the depth of modules to show in the output.
|
39
|
+
#
|
40
|
+
# @example Basic Invocation
|
41
|
+
# RubyTerraform::Commands::Graph.new.execute
|
42
|
+
#
|
8
43
|
class Graph < Base
|
9
44
|
include RubyTerraform::Options::Common
|
10
45
|
|
46
|
+
# @!visibility private
|
11
47
|
def subcommands
|
12
48
|
%w[graph]
|
13
49
|
end
|
14
50
|
|
51
|
+
# @!visibility private
|
52
|
+
# @todo Add plan option.
|
15
53
|
def options
|
16
54
|
%w[
|
17
55
|
-draw-cycles
|