ruby-terraform 0.65.0.pre.3 → 0.65.0.pre.8
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 +5 -5
- data/lib/ruby_terraform.rb +20 -54
- data/lib/ruby_terraform/commands/apply.rb +30 -40
- data/lib/ruby_terraform/commands/base.rb +58 -15
- data/lib/ruby_terraform/commands/destroy.rb +26 -38
- data/lib/ruby_terraform/commands/format.rb +15 -19
- data/lib/ruby_terraform/commands/get.rb +13 -8
- data/lib/ruby_terraform/commands/import.rb +25 -36
- data/lib/ruby_terraform/commands/init.rb +19 -34
- data/lib/ruby_terraform/commands/output.rb +19 -20
- data/lib/ruby_terraform/commands/plan.rb +22 -37
- data/lib/ruby_terraform/commands/refresh.rb +20 -33
- data/lib/ruby_terraform/commands/remote_config.rb +12 -16
- data/lib/ruby_terraform/commands/show.rb +13 -15
- data/lib/ruby_terraform/commands/validate.rb +20 -30
- data/lib/ruby_terraform/commands/workspace.rb +13 -10
- data/lib/ruby_terraform/options.rb +5 -0
- data/lib/ruby_terraform/options/factory.rb +116 -0
- data/lib/ruby_terraform/options/name.rb +43 -0
- data/lib/ruby_terraform/options/types/base.rb +24 -0
- data/lib/ruby_terraform/options/types/boolean.rb +16 -0
- data/lib/ruby_terraform/options/types/flag.rb +16 -0
- data/lib/ruby_terraform/options/types/standard.rb +41 -0
- data/lib/ruby_terraform/options/values/boolean.rb +29 -0
- data/lib/ruby_terraform/output.rb +15 -11
- data/lib/ruby_terraform/version.rb +1 -1
- metadata +12 -4
@@ -1,45 +1,34 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
1
|
require_relative 'base'
|
5
2
|
|
6
3
|
module RubyTerraform
|
7
4
|
module Commands
|
8
5
|
class Import < Base
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
def switches
|
7
|
+
%w[
|
8
|
+
-config
|
9
|
+
-backup
|
10
|
+
-input
|
11
|
+
-no-color
|
12
|
+
-state
|
13
|
+
-var
|
14
|
+
-var-file
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def subcommands(_values)
|
19
|
+
%w[import]
|
20
|
+
end
|
21
|
+
|
22
|
+
def arguments(values)
|
23
|
+
[values[:address], values[:id]]
|
24
|
+
end
|
25
|
+
|
26
|
+
def option_default_values(_opts)
|
27
|
+
{ vars: {}, var_files: [] }
|
28
|
+
end
|
21
29
|
|
22
|
-
|
23
|
-
|
24
|
-
sub = sub.with_option('-config', directory)
|
25
|
-
vars.each do |key, value|
|
26
|
-
var_value = value.is_a?(String) ? value : JSON.generate(value)
|
27
|
-
sub = sub.with_option(
|
28
|
-
'-var', "'#{key}=#{var_value}'", separator: ' '
|
29
|
-
)
|
30
|
-
end
|
31
|
-
sub = sub.with_option('-var-file', var_file) if var_file
|
32
|
-
var_files.each do |file|
|
33
|
-
sub = sub.with_option('-var-file', file)
|
34
|
-
end
|
35
|
-
sub = sub.with_option('-state', state) if state
|
36
|
-
sub = sub.with_option('-input', input) if input
|
37
|
-
sub = sub.with_option('-backup', backup) if backup
|
38
|
-
sub = sub.with_flag('-no-color') if no_color
|
39
|
-
sub
|
40
|
-
end
|
41
|
-
.with_argument(address)
|
42
|
-
.with_argument(id)
|
30
|
+
def option_override_values(opts)
|
31
|
+
{ backup: opts[:no_backup] ? '-' : opts[:backup] }
|
43
32
|
end
|
44
33
|
end
|
45
34
|
end
|
@@ -3,43 +3,28 @@ require_relative 'base'
|
|
3
3
|
module RubyTerraform
|
4
4
|
module Commands
|
5
5
|
class Init < Base
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
def switches
|
7
|
+
%w[
|
8
|
+
-backend
|
9
|
+
-backend-config
|
10
|
+
-force-copy
|
11
|
+
-from-module
|
12
|
+
-get
|
13
|
+
-no-color
|
14
|
+
-plugin-dir
|
15
|
+
]
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
unless force_copy.nil?
|
20
|
-
sub = sub.with_option('-force-copy',
|
21
|
-
force_copy)
|
22
|
-
end
|
23
|
-
sub = sub.with_option('-get', get) unless get.nil?
|
24
|
-
sub = sub.with_option('-from-module', source) if source
|
25
|
-
sub = sub.with_flag('-no-color') if no_color
|
26
|
-
unless plugin_dir.nil?
|
27
|
-
sub = sub.with_option('-plugin-dir',
|
28
|
-
plugin_dir)
|
29
|
-
end
|
30
|
-
backend_config.each do |key, value|
|
31
|
-
sub = sub.with_option(
|
32
|
-
'-backend-config',
|
33
|
-
"'#{key}=#{value}'",
|
34
|
-
separator: ' '
|
35
|
-
)
|
36
|
-
end
|
37
|
-
sub
|
38
|
-
end
|
18
|
+
def subcommands(_values)
|
19
|
+
%w[init]
|
20
|
+
end
|
39
21
|
|
40
|
-
|
22
|
+
def arguments(values)
|
23
|
+
[values[:path]]
|
24
|
+
end
|
41
25
|
|
42
|
-
|
26
|
+
def option_default_values(_opts)
|
27
|
+
{ backend_config: {} }
|
43
28
|
end
|
44
29
|
end
|
45
30
|
end
|
@@ -4,29 +4,28 @@ require_relative 'base'
|
|
4
4
|
module RubyTerraform
|
5
5
|
module Commands
|
6
6
|
class Output < Base
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def initialize_command
|
8
|
+
return if defined?(@stdout) && @stdout.respond_to?(:string)
|
9
|
+
|
10
|
+
@stdout = StringIO.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def switches
|
14
|
+
%w[
|
15
|
+
-json
|
16
|
+
-module
|
17
|
+
-no-color
|
18
|
+
-raw
|
19
|
+
-state
|
20
|
+
]
|
11
21
|
end
|
12
22
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
no_color = opts[:no_color]
|
17
|
-
json = opts[:json]
|
18
|
-
mod = opts[:module]
|
23
|
+
def subcommands(_values)
|
24
|
+
%w[output]
|
25
|
+
end
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
sub = sub.with_flag('-no-color') if no_color
|
23
|
-
sub = sub.with_flag('-json') if json
|
24
|
-
sub = sub.with_option('-state', state) if state
|
25
|
-
sub = sub.with_option('-module', mod) if mod
|
26
|
-
sub
|
27
|
-
end
|
28
|
-
builder = builder.with_argument(name) if name
|
29
|
-
builder
|
27
|
+
def arguments(values)
|
28
|
+
[values[:name]]
|
30
29
|
end
|
31
30
|
|
32
31
|
def do_after(opts)
|
@@ -1,46 +1,31 @@
|
|
1
|
-
require 'json'
|
2
1
|
require_relative 'base'
|
3
2
|
|
4
3
|
module RubyTerraform
|
5
4
|
module Commands
|
6
5
|
class Plan < Base
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
def switches
|
7
|
+
%w[
|
8
|
+
-destroy
|
9
|
+
-input
|
10
|
+
-no-color
|
11
|
+
-out
|
12
|
+
-state
|
13
|
+
-target
|
14
|
+
-var
|
15
|
+
-var-file
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
def subcommands(_values)
|
20
|
+
%w[plan]
|
21
|
+
end
|
22
|
+
|
23
|
+
def arguments(values)
|
24
|
+
[values[:directory]]
|
25
|
+
end
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
vars.each do |key, value|
|
23
|
-
var_value = value.is_a?(String) ? value : JSON.generate(value)
|
24
|
-
sub = sub.with_option(
|
25
|
-
'-var', "'#{key}=#{var_value}'", separator: ' '
|
26
|
-
)
|
27
|
-
end
|
28
|
-
sub = sub.with_option('-var-file', var_file) if var_file
|
29
|
-
var_files.each do |file|
|
30
|
-
sub = sub.with_option('-var-file', file)
|
31
|
-
end
|
32
|
-
sub = sub.with_option('-target', target) if target
|
33
|
-
targets.each do |file|
|
34
|
-
sub = sub.with_option('-target', file)
|
35
|
-
end
|
36
|
-
sub = sub.with_option('-state', state) if state
|
37
|
-
sub = sub.with_option('-out', plan) if plan
|
38
|
-
sub = sub.with_option('-input', input) if input
|
39
|
-
sub = sub.with_flag('-destroy') if destroy
|
40
|
-
sub = sub.with_flag('-no-color') if no_color
|
41
|
-
sub
|
42
|
-
end
|
43
|
-
.with_argument(directory)
|
27
|
+
def option_default_values(_opts)
|
28
|
+
{ vars: {}, var_files: [], targets: [] }
|
44
29
|
end
|
45
30
|
end
|
46
31
|
end
|
@@ -1,42 +1,29 @@
|
|
1
|
-
require 'json'
|
2
1
|
require_relative 'base'
|
3
2
|
|
4
3
|
module RubyTerraform
|
5
4
|
module Commands
|
6
5
|
class Refresh < Base
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
def switches
|
7
|
+
%w[
|
8
|
+
-input
|
9
|
+
-no-color
|
10
|
+
-state
|
11
|
+
-target
|
12
|
+
-var
|
13
|
+
-var-file
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
def subcommands(_values)
|
18
|
+
%w[refresh]
|
19
|
+
end
|
20
|
+
|
21
|
+
def arguments(values)
|
22
|
+
[values[:directory]]
|
23
|
+
end
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
vars.each do |key, value|
|
21
|
-
var_value = value.is_a?(String) ? value : JSON.generate(value)
|
22
|
-
sub = sub.with_option(
|
23
|
-
'-var', "'#{key}=#{var_value}'", separator: ' '
|
24
|
-
)
|
25
|
-
end
|
26
|
-
sub = sub.with_option('-var-file', var_file) if var_file
|
27
|
-
var_files.each do |file|
|
28
|
-
sub = sub.with_option('-var-file', file)
|
29
|
-
end
|
30
|
-
sub = sub.with_option('-state', state) if state
|
31
|
-
sub = sub.with_option('-input', input) if input
|
32
|
-
sub = sub.with_option('-target', target) if target
|
33
|
-
targets.each do |target_name|
|
34
|
-
sub = sub.with_option('-target', target_name)
|
35
|
-
end
|
36
|
-
sub = sub.with_flag('-no-color') if no_color
|
37
|
-
sub
|
38
|
-
end
|
39
|
-
.with_argument(directory)
|
25
|
+
def option_default_values(_opts)
|
26
|
+
{ vars: {}, var_files: [], targets: [] }
|
40
27
|
end
|
41
28
|
end
|
42
29
|
end
|
@@ -3,24 +3,20 @@ require_relative 'base'
|
|
3
3
|
module RubyTerraform
|
4
4
|
module Commands
|
5
5
|
class RemoteConfig < Base
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def switches
|
7
|
+
%w[
|
8
|
+
-backend
|
9
|
+
-backend-config
|
10
|
+
-no-color
|
11
|
+
]
|
12
|
+
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
sub = sub.with_option('-backend', backend) if backend
|
15
|
-
backend_config.each do |key, value|
|
16
|
-
sub = sub.with_option(
|
17
|
-
'-backend-config', "'#{key}=#{value}'", separator: ' '
|
18
|
-
)
|
19
|
-
end
|
14
|
+
def subcommands(_values)
|
15
|
+
%w[remote config]
|
16
|
+
end
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
18
|
+
def option_default_values(_opts)
|
19
|
+
{ backend_config: {} }
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
@@ -1,24 +1,22 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative 'base'
|
4
2
|
|
5
3
|
module RubyTerraform
|
6
4
|
module Commands
|
7
5
|
class Show < Base
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
def switches
|
7
|
+
%w[
|
8
|
+
-json
|
9
|
+
-module-depth
|
10
|
+
-no-color
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
def subcommands(_values)
|
15
|
+
%w[show]
|
16
|
+
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
sub = sub.with_option('-module-depth', module_depth) if module_depth
|
17
|
-
sub = sub.with_flag('-no-color') if no_color
|
18
|
-
sub = sub.with_flag('-json') if json_format
|
19
|
-
sub
|
20
|
-
end
|
21
|
-
.with_argument(path)
|
18
|
+
def arguments(values)
|
19
|
+
[values[:path] || values[:directory]]
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -1,39 +1,29 @@
|
|
1
|
-
require 'json'
|
2
1
|
require_relative 'base'
|
3
2
|
|
4
3
|
module RubyTerraform
|
5
4
|
module Commands
|
6
5
|
class Validate < Base
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
def switches
|
7
|
+
%w[
|
8
|
+
-check-variables
|
9
|
+
-json
|
10
|
+
-no-color
|
11
|
+
-state
|
12
|
+
-var
|
13
|
+
-var-file
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
def subcommands(_values)
|
18
|
+
%w[validate]
|
19
|
+
end
|
20
|
+
|
21
|
+
def arguments(values)
|
22
|
+
[values[:directory]]
|
23
|
+
end
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
vars.each do |key, value|
|
20
|
-
var_value = value.is_a?(String) ? value : JSON.generate(value)
|
21
|
-
sub = sub.with_option(
|
22
|
-
'-var', "'#{key}=#{var_value}'", separator: ' '
|
23
|
-
)
|
24
|
-
end
|
25
|
-
sub = sub.with_option('-var-file', var_file) if var_file
|
26
|
-
var_files.each do |file|
|
27
|
-
sub = sub.with_option('-var-file', file)
|
28
|
-
end
|
29
|
-
sub = sub.with_option('-state', state) if state
|
30
|
-
sub = sub.with_option('-check-variables', check_variables) unless
|
31
|
-
check_variables.nil?
|
32
|
-
sub = sub.with_flag('-no-color') if no_color
|
33
|
-
sub = sub.with_flag('-json') if json_format
|
34
|
-
sub
|
35
|
-
end
|
36
|
-
.with_argument(directory)
|
25
|
+
def option_default_values(_opts)
|
26
|
+
{ vars: {}, var_files: [] }
|
37
27
|
end
|
38
28
|
end
|
39
29
|
end
|