ruby-terraform 0.65.0.pre.15 → 1.0.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -15
- data/README.md +148 -397
- data/Rakefile +25 -0
- data/lib/ruby_terraform.rb +707 -45
- data/lib/ruby_terraform/commands.rb +0 -2
- data/lib/ruby_terraform/commands/apply.rb +7 -7
- data/lib/ruby_terraform/commands/base.rb +4 -1
- data/lib/ruby_terraform/commands/destroy.rb +6 -5
- data/lib/ruby_terraform/commands/force_unlock.rb +6 -4
- data/lib/ruby_terraform/commands/format.rb +8 -4
- data/lib/ruby_terraform/commands/get.rb +6 -4
- data/lib/ruby_terraform/commands/graph.rb +11 -3
- data/lib/ruby_terraform/commands/import.rb +8 -7
- data/lib/ruby_terraform/commands/init.rb +16 -6
- data/lib/ruby_terraform/commands/login.rb +2 -2
- data/lib/ruby_terraform/commands/logout.rb +2 -2
- data/lib/ruby_terraform/commands/output.rb +2 -2
- data/lib/ruby_terraform/commands/plan.rb +6 -3
- data/lib/ruby_terraform/commands/providers.rb +9 -3
- data/lib/ruby_terraform/commands/providers_lock.rb +10 -7
- data/lib/ruby_terraform/commands/providers_mirror.rb +3 -3
- data/lib/ruby_terraform/commands/providers_schema.rb +21 -2
- data/lib/ruby_terraform/commands/refresh.rb +70 -3
- data/lib/ruby_terraform/commands/show.rb +26 -3
- data/lib/ruby_terraform/commands/state_list.rb +54 -3
- data/lib/ruby_terraform/commands/state_move.rb +64 -6
- data/lib/ruby_terraform/commands/state_pull.rb +24 -2
- data/lib/ruby_terraform/commands/state_push.rb +49 -3
- data/lib/ruby_terraform/commands/state_remove.rb +55 -7
- data/lib/ruby_terraform/commands/state_replace_provider.rb +39 -6
- data/lib/ruby_terraform/commands/state_show.rb +26 -2
- data/lib/ruby_terraform/commands/taint.rb +63 -2
- data/lib/ruby_terraform/commands/untaint.rb +55 -2
- data/lib/ruby_terraform/commands/validate.rb +51 -6
- data/lib/ruby_terraform/commands/workspace_delete.rb +29 -7
- data/lib/ruby_terraform/commands/workspace_list.rb +21 -6
- data/lib/ruby_terraform/commands/workspace_new.rb +28 -7
- data/lib/ruby_terraform/commands/workspace_select.rb +23 -7
- data/lib/ruby_terraform/commands/workspace_show.rb +17 -2
- data/lib/ruby_terraform/options.rb +1 -1
- data/lib/ruby_terraform/options/definition.rb +3 -1
- data/lib/ruby_terraform/options/definitions.rb +12 -3
- data/lib/ruby_terraform/options/{common.rb → global.rb} +1 -1
- data/lib/ruby_terraform/options/types.rb +0 -1
- data/lib/ruby_terraform/options/types/flag.rb +8 -4
- data/lib/ruby_terraform/options/types/standard.rb +20 -6
- data/lib/ruby_terraform/version.rb +1 -1
- data/ruby_terraform.gemspec +2 -2
- metadata +9 -12
- data/lib/ruby_terraform/commands/clean.rb +0 -26
- data/lib/ruby_terraform/commands/remote_config.rb +0 -25
- data/lib/ruby_terraform/options/types/base.rb +0 -19
@@ -1,17 +1,65 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base'
|
4
|
-
require_relative '../options/
|
4
|
+
require_relative '../options/global'
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform validate+ command which checks whether a
|
9
|
+
# configuration is valid.
|
10
|
+
#
|
11
|
+
# Validates the configuration files in a directory, referring only to the
|
12
|
+
# configuration and not accessing any remote services such as remote state,
|
13
|
+
# provider APIs, etc.
|
14
|
+
#
|
15
|
+
# Validate runs checks that verify whether a configuration is syntactically
|
16
|
+
# valid and internally consistent, regardless of any provided variables or
|
17
|
+
# existing state. It is thus primarily useful for general verification of
|
18
|
+
# reusable modules, including correctness of attribute names and value
|
19
|
+
# types.
|
20
|
+
#
|
21
|
+
# It is safe to run this command automatically, for example as a post-save
|
22
|
+
# check in a text editor or as a test step for a re-usable module in a CI
|
23
|
+
# system.
|
24
|
+
#
|
25
|
+
# Validation requires an initialized working directory with any referenced
|
26
|
+
# plugins and modules installed. To initialize a working directory for
|
27
|
+
# validation without accessing any configured remote backend, use the {Init}
|
28
|
+
# command passing +:backend+ as +false+.
|
29
|
+
#
|
30
|
+
# To verify configuration in the context of a particular run (a particular
|
31
|
+
# target workspace, input variable values, etc), use the {Plan} command
|
32
|
+
# instead, which includes an implied validation check.
|
33
|
+
#
|
34
|
+
# For options accepted on construction, see {#initialize}.
|
35
|
+
#
|
36
|
+
# When executing an instance of {Validate} via {#execute}, the following
|
37
|
+
# options are supported:
|
38
|
+
#
|
39
|
+
# * +:directory+: the path to a directory containing terraform configuration
|
40
|
+
# (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
|
41
|
+
# instead).
|
42
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
43
|
+
# the given subcommand.
|
44
|
+
# * +:json+: whether or not to produce output in a machine-readable JSON
|
45
|
+
# format, suitable for use in text editor integrations and other automated
|
46
|
+
# systems; always disables color; defaults to +false+.
|
47
|
+
# * +:no_color+: whether or not the output from the command should be in
|
48
|
+
# color; defaults to +false+.
|
49
|
+
#
|
50
|
+
# @example Basic Invocation
|
51
|
+
# RubyTerraform::Commands::Validate.new.execute(
|
52
|
+
# directory: 'infra/networking')
|
53
|
+
#
|
8
54
|
class Validate < Base
|
9
|
-
include RubyTerraform::Options::
|
55
|
+
include RubyTerraform::Options::Global
|
10
56
|
|
57
|
+
# @!visibility private
|
11
58
|
def subcommands
|
12
59
|
%w[validate]
|
13
60
|
end
|
14
61
|
|
62
|
+
# @!visibility private
|
15
63
|
def options
|
16
64
|
%w[
|
17
65
|
-json
|
@@ -19,13 +67,10 @@ module RubyTerraform
|
|
19
67
|
] + super
|
20
68
|
end
|
21
69
|
|
70
|
+
# @!visibility private
|
22
71
|
def arguments(parameters)
|
23
72
|
[parameters[:directory]]
|
24
73
|
end
|
25
|
-
|
26
|
-
def parameter_defaults(_parameters)
|
27
|
-
{ vars: {}, var_files: [] }
|
28
|
-
end
|
29
74
|
end
|
30
75
|
end
|
31
76
|
end
|
@@ -1,17 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base'
|
4
|
-
require_relative '../options/
|
4
|
+
require_relative '../options/global'
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform workspace delete+ command which deletes a workspace.
|
9
|
+
#
|
10
|
+
# For options accepted on construction, see {#initialize}.
|
11
|
+
#
|
12
|
+
# When executing an instance of {WorkspaceDelete} via {#execute}, the
|
13
|
+
# following options are supported:
|
14
|
+
#
|
15
|
+
# * +:name+: the name of the workspace to delete; required.
|
16
|
+
# * +:directory+: the path to a directory containing terraform configuration
|
17
|
+
# (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
|
18
|
+
# instead).
|
19
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
20
|
+
# the given subcommand.
|
21
|
+
# * +:force+: whether or not to remove a non-empty workspace; defaults to
|
22
|
+
# +false+.
|
23
|
+
# * +:lock+: when +true+, locks the state file when locking is supported;
|
24
|
+
# when +false+, does not lock the state file; defaults to +true+.
|
25
|
+
# * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
|
26
|
+
#
|
27
|
+
# @example Basic Invocation
|
28
|
+
# RubyTerraform::Commands::WorkspaceDelete.new.execute(
|
29
|
+
# name: 'example')
|
30
|
+
#
|
8
31
|
class WorkspaceDelete < Base
|
9
|
-
include RubyTerraform::Options::
|
32
|
+
include RubyTerraform::Options::Global
|
10
33
|
|
34
|
+
# @!visibility private
|
11
35
|
def subcommands
|
12
36
|
%w[workspace delete]
|
13
37
|
end
|
14
38
|
|
39
|
+
# @!visibility private
|
15
40
|
def options
|
16
41
|
%w[
|
17
42
|
-force
|
@@ -20,12 +45,9 @@ module RubyTerraform
|
|
20
45
|
] + super
|
21
46
|
end
|
22
47
|
|
48
|
+
# @!visibility private
|
23
49
|
def arguments(parameters)
|
24
|
-
[parameters[:
|
25
|
-
end
|
26
|
-
|
27
|
-
def parameter_defaults(_parameters)
|
28
|
-
{ directory: nil }
|
50
|
+
[parameters[:name], parameters[:directory]]
|
29
51
|
end
|
30
52
|
end
|
31
53
|
end
|
@@ -1,24 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base'
|
4
|
-
require_relative '../options/
|
4
|
+
require_relative '../options/global'
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform workspace list+ command which lists workspaces.
|
9
|
+
#
|
10
|
+
# For options accepted on construction, see {#initialize}.
|
11
|
+
#
|
12
|
+
# When executing an instance of {WorkspaceList} via {#execute}, the
|
13
|
+
# following options are supported:
|
14
|
+
#
|
15
|
+
# * +:directory+: the path to a directory containing terraform configuration
|
16
|
+
# (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
|
17
|
+
# instead).
|
18
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
19
|
+
# the given subcommand.
|
20
|
+
#
|
21
|
+
# @example Basic Invocation
|
22
|
+
# RubyTerraform::Commands::WorkspaceList.new.execute(
|
23
|
+
# directory: 'infra/networking')
|
24
|
+
#
|
8
25
|
class WorkspaceList < Base
|
9
|
-
include RubyTerraform::Options::
|
26
|
+
include RubyTerraform::Options::Global
|
10
27
|
|
28
|
+
# @!visibility private
|
11
29
|
def subcommands
|
12
30
|
%w[workspace list]
|
13
31
|
end
|
14
32
|
|
33
|
+
# @!visibility private
|
15
34
|
def arguments(parameters)
|
16
35
|
[parameters[:directory]]
|
17
36
|
end
|
18
|
-
|
19
|
-
def parameter_defaults(_parameters)
|
20
|
-
{ directory: nil }
|
21
|
-
end
|
22
37
|
end
|
23
38
|
end
|
24
39
|
end
|
@@ -1,17 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base'
|
4
|
-
require_relative '../options/
|
4
|
+
require_relative '../options/global'
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform workspace new+ command which creates a new workspace.
|
9
|
+
#
|
10
|
+
# For options accepted on construction, see {#initialize}.
|
11
|
+
#
|
12
|
+
# When executing an instance of {WorkspaceNew} via {#execute}, the
|
13
|
+
# following options are supported:
|
14
|
+
#
|
15
|
+
# * +:name+: the name of the workspace to create; required.
|
16
|
+
# * +:directory+: the path to a directory containing terraform configuration
|
17
|
+
# (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
|
18
|
+
# instead).
|
19
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
20
|
+
# the given subcommand.
|
21
|
+
# * +:lock+: when +true+, locks the state file when locking is supported;
|
22
|
+
# when +false+, does not lock the state file; defaults to +true+.
|
23
|
+
# * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
|
24
|
+
# * +:state+: the path to a state file to copy into the new workspace.
|
25
|
+
#
|
26
|
+
# @example Basic Invocation
|
27
|
+
# RubyTerraform::Commands::WorkspaceNew.new.execute(
|
28
|
+
# name: 'example')
|
29
|
+
#
|
8
30
|
class WorkspaceNew < Base
|
9
|
-
include RubyTerraform::Options::
|
31
|
+
include RubyTerraform::Options::Global
|
10
32
|
|
33
|
+
# @!visibility private
|
11
34
|
def subcommands
|
12
35
|
%w[workspace new]
|
13
36
|
end
|
14
37
|
|
38
|
+
# @!visibility private
|
15
39
|
def options
|
16
40
|
%w[
|
17
41
|
-lock
|
@@ -20,12 +44,9 @@ module RubyTerraform
|
|
20
44
|
] + super
|
21
45
|
end
|
22
46
|
|
47
|
+
# @!visibility private
|
23
48
|
def arguments(parameters)
|
24
|
-
[parameters[:
|
25
|
-
end
|
26
|
-
|
27
|
-
def parameter_defaults(_parameters)
|
28
|
-
{ directory: nil }
|
49
|
+
[parameters[:name], parameters[:directory]]
|
29
50
|
end
|
30
51
|
end
|
31
52
|
end
|
@@ -1,23 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base'
|
4
|
-
require_relative '../options/
|
4
|
+
require_relative '../options/global'
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform workspace select+ command which selects a workspace.
|
9
|
+
#
|
10
|
+
# For options accepted on construction, see {#initialize}.
|
11
|
+
#
|
12
|
+
# When executing an instance of {WorkspaceSelect} via {#execute}, the
|
13
|
+
# following options are supported:
|
14
|
+
#
|
15
|
+
# * +:name+: the name of the workspace to select; required.
|
16
|
+
# * +:directory+: the path to a directory containing terraform configuration
|
17
|
+
# (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
|
18
|
+
# instead).
|
19
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
20
|
+
# the given subcommand.
|
21
|
+
#
|
22
|
+
# @example BasicInvocation
|
23
|
+
# RubyTerraform::Commands::WorkspaceSelect.new.execute(
|
24
|
+
# name: 'example')
|
25
|
+
#
|
8
26
|
class WorkspaceSelect < Base
|
9
|
-
include RubyTerraform::Options::
|
27
|
+
include RubyTerraform::Options::Global
|
10
28
|
|
29
|
+
# @!visibility private
|
11
30
|
def subcommands
|
12
31
|
%w[workspace select]
|
13
32
|
end
|
14
33
|
|
34
|
+
# @!visibility private
|
15
35
|
def arguments(parameters)
|
16
|
-
[parameters[:
|
17
|
-
end
|
18
|
-
|
19
|
-
def parameter_defaults(_parameters)
|
20
|
-
{ directory: nil }
|
36
|
+
[parameters[:name], parameters[:directory]]
|
21
37
|
end
|
22
38
|
end
|
23
39
|
end
|
@@ -1,13 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base'
|
4
|
-
require_relative '../options/
|
4
|
+
require_relative '../options/global'
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform workspace show+ command which shows the name of the
|
9
|
+
# current workspace.
|
10
|
+
#
|
11
|
+
# For options accepted on construction, see {#initialize}.
|
12
|
+
#
|
13
|
+
# When executing an instance of {WorkspaceSelect} via {#execute}, the
|
14
|
+
# following options are supported:
|
15
|
+
#
|
16
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
17
|
+
# the given subcommand.
|
18
|
+
#
|
19
|
+
# @example Basic Invocation
|
20
|
+
# RubyTerraform::Commands::WorkspaceShow.new.execute
|
21
|
+
#
|
8
22
|
class WorkspaceShow < Base
|
9
|
-
include RubyTerraform::Options::
|
23
|
+
include RubyTerraform::Options::Global
|
10
24
|
|
25
|
+
# @!visibility private
|
11
26
|
def subcommands
|
12
27
|
%w[workspace show]
|
13
28
|
end
|
@@ -16,6 +16,7 @@ module RubyTerraform
|
|
16
16
|
:override_keys,
|
17
17
|
:extra_keys,
|
18
18
|
:separator,
|
19
|
+
:placement,
|
19
20
|
:repeatable?
|
20
21
|
)
|
21
22
|
# rubocop:disable Metrics/MethodLength
|
@@ -28,6 +29,7 @@ module RubyTerraform
|
|
28
29
|
value_type: Values.resolve(opts[:value_type]) || Values::String,
|
29
30
|
repeatable: opts[:repeatable] || false,
|
30
31
|
separator: opts[:separator],
|
32
|
+
placement: opts[:placement],
|
31
33
|
extra_keys:
|
32
34
|
{ singular: [], plural: [] }
|
33
35
|
.merge(opts[:extra_keys] || {}),
|
@@ -97,7 +99,7 @@ module RubyTerraform
|
|
97
99
|
end
|
98
100
|
|
99
101
|
def build_option(value)
|
100
|
-
option_type.new(name, value, separator: separator)
|
102
|
+
option_type.new(name, value, separator: separator, placement: placement)
|
101
103
|
end
|
102
104
|
|
103
105
|
def build_value(value)
|
@@ -22,7 +22,7 @@ module RubyTerraform
|
|
22
22
|
end,
|
23
23
|
|
24
24
|
# string repeatable options
|
25
|
-
%w[-var-file -target -platform].map do |o|
|
25
|
+
%w[-var-file -target -platform -plugin-dir].map do |o|
|
26
26
|
definition(
|
27
27
|
name: o, option_type: :standard, value_type: :string,
|
28
28
|
repeatable: true
|
@@ -56,6 +56,7 @@ module RubyTerraform
|
|
56
56
|
-detailed-exitcode
|
57
57
|
-diff
|
58
58
|
-draw-cycles
|
59
|
+
-dry-run
|
59
60
|
-force
|
60
61
|
-force-copy
|
61
62
|
-ignore-remote-version
|
@@ -73,14 +74,15 @@ module RubyTerraform
|
|
73
74
|
%w[
|
74
75
|
-backup
|
75
76
|
-backup-out
|
76
|
-
-chdir
|
77
77
|
-from-module
|
78
78
|
-fs-mirror
|
79
|
+
-id
|
79
80
|
-lock-timeout
|
81
|
+
-lockfile
|
80
82
|
-module-depth
|
81
83
|
-net-mirror
|
82
84
|
-parallelism
|
83
|
-
-
|
85
|
+
-plan
|
84
86
|
-provider
|
85
87
|
-state
|
86
88
|
-state-out
|
@@ -97,6 +99,13 @@ module RubyTerraform
|
|
97
99
|
definition(
|
98
100
|
name: '-out', option_type: :standard, value_type: :string,
|
99
101
|
extra_keys: { singular: %i[plan] }
|
102
|
+
),
|
103
|
+
|
104
|
+
# global options
|
105
|
+
definition(
|
106
|
+
name: '-chdir', option_type: :standard, value_type: :string,
|
107
|
+
placement: :after_command,
|
108
|
+
extra_keys: { singular: %i[working_directory] }
|
100
109
|
)
|
101
110
|
].flatten.freeze
|
102
111
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'base'
|
4
|
-
require_relative '../values/boolean'
|
5
|
-
|
6
3
|
module RubyTerraform
|
7
4
|
module Options
|
8
5
|
module Types
|
9
|
-
class Flag <
|
6
|
+
class Flag < ImmutableStruct.new(
|
7
|
+
:name,
|
8
|
+
:value
|
9
|
+
)
|
10
|
+
def initialize(name, value, **_opts)
|
11
|
+
super(name: name, value: value)
|
12
|
+
end
|
13
|
+
|
10
14
|
def apply(builder)
|
11
15
|
value.resolve ? builder.with_flag(name) : builder
|
12
16
|
end
|