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.
@@ -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 configure_command(builder, opts)
10
- directory = opts[:directory]
11
- vars = opts[:vars] || {}
12
- var_file = opts[:var_file]
13
- var_files = opts[:var_files] || []
14
- no_color = opts[:no_color]
15
- no_backup = opts[:no_backup]
16
- backup = no_backup ? '-' : opts[:backup]
17
- state = opts[:state]
18
- input = opts[:input]
19
- address = opts[:address]
20
- id = opts[:id]
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
- builder
23
- .with_subcommand('import') do |sub|
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 configure_command(builder, opts)
7
- no_color = opts[:no_color]
8
- backend = opts[:backend]
9
- get = opts[:get]
10
- backend_config = opts[:backend_config] || {}
11
- source = opts[:from_module]
12
- path = opts[:path]
13
- plugin_dir = opts[:plugin_dir]
14
- force_copy = opts[:force_copy]
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
- builder = builder
17
- .with_subcommand('init') do |sub|
18
- sub = sub.with_option('-backend', backend) unless backend.nil?
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
- builder = builder.with_argument(path) if path
22
+ def arguments(values)
23
+ [values[:path]]
24
+ end
41
25
 
42
- builder
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 initialize(**kwargs)
8
- super(**kwargs)
9
- @stdout = StringIO.new unless
10
- defined?(@stdout) && @stdout.respond_to?(:string)
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 configure_command(builder, opts)
14
- name = opts[:name]
15
- state = opts[:state]
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
- builder = builder
21
- .with_subcommand('output') do |sub|
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 configure_command(builder, opts)
8
- directory = opts[:directory]
9
- vars = opts[:vars] || {}
10
- var_file = opts[:var_file]
11
- var_files = opts[:var_files] || []
12
- target = opts[:target]
13
- targets = opts[:targets] || []
14
- state = opts[:state]
15
- plan = opts[:plan]
16
- input = opts[:input]
17
- destroy = opts[:destroy]
18
- no_color = opts[:no_color]
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
- builder
21
- .with_subcommand('plan') do |sub|
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 configure_command(builder, opts)
8
- directory = opts[:directory]
9
- vars = opts[:vars] || {}
10
- var_file = opts[:var_file]
11
- var_files = opts[:var_files] || []
12
- state = opts[:state]
13
- input = opts[:input]
14
- target = opts[:target]
15
- targets = opts[:targets] || []
16
- no_color = opts[:no_color]
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
- builder
19
- .with_subcommand('refresh') do |sub|
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 configure_command(builder, opts)
7
- backend = opts[:backend]
8
- no_color = opts[:no_color]
9
- backend_config = opts[:backend_config] || {}
6
+ def switches
7
+ %w[
8
+ -backend
9
+ -backend-config
10
+ -no-color
11
+ ]
12
+ end
10
13
 
11
- builder
12
- .with_subcommand('remote')
13
- .with_subcommand('config') do |sub|
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
- sub = sub.with_flag('-no-color') if no_color
22
- sub
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 configure_command(builder, opts)
9
- path = opts[:path] || opts[:directory]
10
- json_format = opts[:json]
11
- no_color = opts[:no_color]
12
- module_depth = opts[:module_depth]
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
- builder
15
- .with_subcommand('show') do |sub|
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 configure_command(builder, opts)
8
- directory = opts[:directory]
9
- vars = opts[:vars] || {}
10
- var_file = opts[:var_file]
11
- var_files = opts[:var_files] || []
12
- state = opts[:state]
13
- check_variables = opts[:check_variables]
14
- no_color = opts[:no_color]
15
- json_format = opts[:json]
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
- builder
18
- .with_subcommand('validate') do |sub|
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