ruby-terraform 0.65.0.pre.6 → 0.65.0.pre.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5cfd39cb3e8dbe09c0589280ac5b3879e913a9588574420bb285d89a8507217
4
- data.tar.gz: 0e87b3b820aff40c28c38073735c4da17c14f95081b6a57f861df034a326bfa1
3
+ metadata.gz: 9addf5887a0f81258238fceea9f31f92f8653b4593c0684e3511723e5d7ee969
4
+ data.tar.gz: 660b6fb332e8b93e4ca3f7bb8dc1b48052a2116130273968d148d983b9ee0f4f
5
5
  SHA512:
6
- metadata.gz: 86d696b30097ac1248ae4f421c591307bad5002ce91fb0352e30334d1c5861ec8abd43c734e6fb1eb0c6efefb07d7f9b09706684bd97b616a6f556e2e6fb9064
7
- data.tar.gz: c55bd0a0a10da6bf852b097c17e11890c26ddbeb123edff321a31d5c89fa09404145299c69cda3b403979a0f88d6eca7d9ebf676b5e570933cd4e14f63b36483
6
+ metadata.gz: 444f51e2e53816404a78770d21873b060b2b117fe36a34516c1c1748db60d87ed10a1fa07bd75e0d7ff010617b1ce7ed3618ede7bc80263539be6454a703b962
7
+ data.tar.gz: cbb17a6a9b74be5a809b3d68058f383634482fdc3aa06151fc70b165195f230dd692da4b8494a20ffbe09bb7075acd15d9238b07a8a5dc53c3d4590990369000
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.65.0.pre.6)
4
+ ruby-terraform (0.65.0.pre.7)
5
5
  lino (>= 2.3)
6
6
 
7
7
  GEM
@@ -1,5 +1,6 @@
1
1
  require 'ruby_terraform/version'
2
2
  require 'ruby_terraform/errors'
3
+ require 'ruby_terraform/options'
3
4
  require 'ruby_terraform/commands'
4
5
  require 'logger'
5
6
 
@@ -3,14 +3,26 @@ require_relative 'base'
3
3
  module RubyTerraform
4
4
  module Commands
5
5
  class Apply < Base
6
- def sub_commands(_values)
6
+ def subcommands(_values)
7
7
  %w[apply]
8
8
  end
9
9
 
10
+ # rubocop:disable Metrics/MethodLength
10
11
  def switches
11
- %w[-backup -lock -lock-timeout -input -auto-approve -no-color -state
12
- -target -var -var-file]
12
+ %w[
13
+ -auto-approve
14
+ -backup
15
+ -input
16
+ -lock
17
+ -lock-timeout
18
+ -no-color
19
+ -state
20
+ -target
21
+ -var
22
+ -var-file
23
+ ]
13
24
  end
25
+ # rubocop:enable Metrics/MethodLength
14
26
 
15
27
  def arguments(values)
16
28
  [values[:plan] || values[:directory]]
@@ -61,7 +61,7 @@ module RubyTerraform
61
61
  .with_options_after_subcommands
62
62
  .with_option_separator('=')
63
63
  .with_appliables(options(values))
64
- .with_subcommands(sub_commands(values))
64
+ .with_subcommands(subcommands(values))
65
65
  .with_arguments(arguments(values))
66
66
  .build
67
67
  end
@@ -80,7 +80,7 @@ module RubyTerraform
80
80
  {}
81
81
  end
82
82
 
83
- def sub_commands(_values)
83
+ def subcommands(_values)
84
84
  []
85
85
  end
86
86
 
@@ -4,10 +4,19 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Destroy < Base
6
6
  def switches
7
- %w[-backup -auto-approve -force -no-color -state -target -var -var-file]
7
+ %w[
8
+ -auto-approve
9
+ -backup
10
+ -force
11
+ -no-color
12
+ -state
13
+ -target
14
+ -var
15
+ -var-file
16
+ ]
8
17
  end
9
18
 
10
- def sub_commands(_values)
19
+ def subcommands(_values)
11
20
  %w[destroy]
12
21
  end
13
22
 
@@ -4,10 +4,17 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Format < Base
6
6
  def switches
7
- %w[-list -write -diff -check -recursive -no-color]
7
+ %w[
8
+ -check
9
+ -diff
10
+ -list
11
+ -no-color
12
+ -recursive
13
+ -write
14
+ ]
8
15
  end
9
16
 
10
- def sub_commands(_values)
17
+ def subcommands(_values)
11
18
  %w[fmt]
12
19
  end
13
20
 
@@ -4,10 +4,13 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Get < Base
6
6
  def switches
7
- %w[-update -no-color]
7
+ %w[
8
+ -no-color
9
+ -update
10
+ ]
8
11
  end
9
12
 
10
- def sub_commands(_values)
13
+ def subcommands(_values)
11
14
  %w[get]
12
15
  end
13
16
 
@@ -4,10 +4,18 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Import < Base
6
6
  def switches
7
- %w[-config -backup -input -no-color -state -var -var-file]
7
+ %w[
8
+ -config
9
+ -backup
10
+ -input
11
+ -no-color
12
+ -state
13
+ -var
14
+ -var-file
15
+ ]
8
16
  end
9
17
 
10
- def sub_commands(_values)
18
+ def subcommands(_values)
11
19
  %w[import]
12
20
  end
13
21
 
@@ -4,11 +4,18 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Init < Base
6
6
  def switches
7
- %w[-backend -backend-config -from-module -get -no-color -plugin-dir
8
- -force-copy]
7
+ %w[
8
+ -backend
9
+ -backend-config
10
+ -force-copy
11
+ -from-module
12
+ -get
13
+ -no-color
14
+ -plugin-dir
15
+ ]
9
16
  end
10
17
 
11
- def sub_commands(_values)
18
+ def subcommands(_values)
12
19
  %w[init]
13
20
  end
14
21
 
@@ -11,10 +11,16 @@ module RubyTerraform
11
11
  end
12
12
 
13
13
  def switches
14
- %w[-json -raw -no-color -state -module]
14
+ %w[
15
+ -json
16
+ -module
17
+ -no-color
18
+ -raw
19
+ -state
20
+ ]
15
21
  end
16
22
 
17
- def sub_commands(_values)
23
+ def subcommands(_values)
18
24
  %w[output]
19
25
  end
20
26
 
@@ -4,10 +4,19 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Plan < Base
6
6
  def switches
7
- %w[-destroy -input -no-color -out -state -target -var -var-file]
7
+ %w[
8
+ -destroy
9
+ -input
10
+ -no-color
11
+ -out
12
+ -state
13
+ -target
14
+ -var
15
+ -var-file
16
+ ]
8
17
  end
9
18
 
10
- def sub_commands(_values)
19
+ def subcommands(_values)
11
20
  %w[plan]
12
21
  end
13
22
 
@@ -4,10 +4,17 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Refresh < Base
6
6
  def switches
7
- %w[-input -no-color -state -target -var -var-file]
7
+ %w[
8
+ -input
9
+ -no-color
10
+ -state
11
+ -target
12
+ -var
13
+ -var-file
14
+ ]
8
15
  end
9
16
 
10
- def sub_commands(_values)
17
+ def subcommands(_values)
11
18
  %w[refresh]
12
19
  end
13
20
 
@@ -4,10 +4,14 @@ module RubyTerraform
4
4
  module Commands
5
5
  class RemoteConfig < Base
6
6
  def switches
7
- %w[-backend -backend-config -no-color]
7
+ %w[
8
+ -backend
9
+ -backend-config
10
+ -no-color
11
+ ]
8
12
  end
9
13
 
10
- def sub_commands(_values)
14
+ def subcommands(_values)
11
15
  %w[remote config]
12
16
  end
13
17
 
@@ -4,10 +4,14 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Show < Base
6
6
  def switches
7
- %w[-json -no-color -module-depth]
7
+ %w[
8
+ -json
9
+ -module-depth
10
+ -no-color
11
+ ]
8
12
  end
9
13
 
10
- def sub_commands(_values)
14
+ def subcommands(_values)
11
15
  %w[show]
12
16
  end
13
17
 
@@ -4,10 +4,17 @@ module RubyTerraform
4
4
  module Commands
5
5
  class Validate < Base
6
6
  def switches
7
- %w[-json -no-color -var -var-file -state -check-variables] + super
7
+ %w[
8
+ -check-variables
9
+ -json
10
+ -no-color
11
+ -state
12
+ -var
13
+ -var-file
14
+ ]
8
15
  end
9
16
 
10
- def sub_commands(_values)
17
+ def subcommands(_values)
11
18
  %w[validate]
12
19
  end
13
20
 
@@ -3,7 +3,7 @@ require_relative 'base'
3
3
  module RubyTerraform
4
4
  module Commands
5
5
  class Workspace < Base
6
- def sub_commands(values)
6
+ def subcommands(values)
7
7
  commands = ['workspace', values[:operation]]
8
8
  if values[:workspace] && values[:operation] != 'list'
9
9
  commands << values[:workspace]
@@ -0,0 +1,5 @@
1
+ require_relative 'options/name'
2
+ require_relative 'options/types/flag'
3
+ require_relative 'options/types/boolean'
4
+ require_relative 'options/types/standard'
5
+ require_relative 'options/factory'
@@ -1,61 +1,61 @@
1
- require_relative 'switch'
2
- require_relative 'boolean'
3
- require_relative 'flag'
4
- require_relative 'standard'
1
+ require_relative 'name'
2
+ require_relative 'types/boolean'
3
+ require_relative 'types/flag'
4
+ require_relative 'types/standard'
5
5
 
6
6
  module RubyTerraform
7
7
  module Options
8
8
  class Factory
9
- PLURAL_SWITCHES =
9
+ PLURAL_OPTIONS =
10
10
  Set.new(
11
11
  %w[
12
- -var
13
- -target
14
- -var-file
15
- ]
12
+ -var
13
+ -target
14
+ -var-file
15
+ ]
16
16
  ).freeze
17
17
 
18
- BOOLEAN_SWITCHES =
18
+ BOOLEAN_OPTIONS =
19
19
  Set.new(
20
20
  %w[
21
- -auto-approve
22
- -backend
23
- -get
24
- -get-plugins
25
- -input
26
- -list
27
- -lock
28
- -refresh
29
- -upgrade
30
- -verify-plugins
31
- -write
32
- ]
21
+ -auto-approve
22
+ -backend
23
+ -get
24
+ -get-plugins
25
+ -input
26
+ -list
27
+ -lock
28
+ -refresh
29
+ -upgrade
30
+ -verify-plugins
31
+ -write
32
+ ]
33
33
  ).freeze
34
34
 
35
- FLAG_SWITCHES =
35
+ FLAG_OPTIONS =
36
36
  Set.new(
37
37
  %w[
38
- -allow-missing
39
- -allow-missing-config
40
- -check
41
- -compact-warnings
42
- -destroy
43
- -detailed-exitcode
44
- -diff
45
- -draw-cycles
46
- -force
47
- -force-copy
48
- -ignore-remote-version
49
- -json
50
- -no-color
51
- -raw
52
- -reconfigure
53
- -recursive
54
- -update
55
- ]
38
+ -allow-missing
39
+ -allow-missing-config
40
+ -check
41
+ -compact-warnings
42
+ -destroy
43
+ -detailed-exitcode
44
+ -diff
45
+ -draw-cycles
46
+ -force
47
+ -force-copy
48
+ -ignore-remote-version
49
+ -json
50
+ -no-color
51
+ -raw
52
+ -reconfigure
53
+ -recursive
54
+ -update
55
+ ]
56
56
  ).freeze
57
57
 
58
- OVERRIDE_SWITCHES =
58
+ OVERRIDE_OPTIONS =
59
59
  {
60
60
  config: :directory,
61
61
  out: :plan
@@ -67,49 +67,49 @@ module RubyTerraform
67
67
 
68
68
  private_class_method :new
69
69
 
70
- def initialize(values, switches)
71
- @switches = switches.map { |switch| Switch.new(switch) }
70
+ def initialize(values, names)
71
+ @names = names.map { |switch| Name.new(switch) }
72
72
  @values = values
73
73
  end
74
74
 
75
75
  def from
76
- switches.each_with_object([]) do |switch, options|
77
- options.append(*options_from_switch(switch))
76
+ names.each_with_object([]) do |name, options|
77
+ options.append(*options_from_name(name))
78
78
  end
79
79
  end
80
80
 
81
81
  private
82
82
 
83
- attr_reader :switches, :values
83
+ attr_reader :names, :values
84
84
 
85
- def options_from_switch(switch)
86
- return plural_options(switch) if PLURAL_SWITCHES.include?(switch)
87
- return boolean_option(switch) if BOOLEAN_SWITCHES.include?(switch)
88
- return flag_option(switch) if FLAG_SWITCHES.include?(switch)
89
- return override_option(switch) if OVERRIDE_SWITCHES.key?(switch.as_key)
85
+ def options_from_name(name)
86
+ return plural_options(name) if PLURAL_OPTIONS.include?(name)
87
+ return boolean_option(name) if BOOLEAN_OPTIONS.include?(name)
88
+ return flag_option(name) if FLAG_OPTIONS.include?(name)
89
+ return override_option(name) if OVERRIDE_OPTIONS.key?(name.as_key)
90
90
 
91
- standard_option(switch, switch.as_key)
91
+ standard_option(name, name.as_key)
92
92
  end
93
93
 
94
- def boolean_option(switch)
95
- [Boolean.new(switch.to_s, values[switch.as_key])]
94
+ def boolean_option(name)
95
+ [Types::Boolean.new(name.to_s, values[name.as_key])]
96
96
  end
97
97
 
98
- def flag_option(switch)
99
- [Flag.new(switch.to_s, values[switch.as_key])]
98
+ def flag_option(name)
99
+ [Types::Flag.new(name.to_s, values[name.as_key])]
100
100
  end
101
101
 
102
- def standard_option(switch, hash_key)
103
- [Standard.new(switch.to_s, values[hash_key])]
102
+ def standard_option(name, hash_key)
103
+ [Types::Standard.new(name.to_s, values[hash_key])]
104
104
  end
105
105
 
106
- def override_option(switch)
107
- standard_option(switch, OVERRIDE_SWITCHES[switch.as_key])
106
+ def override_option(name)
107
+ standard_option(name, OVERRIDE_OPTIONS[name.as_key])
108
108
  end
109
109
 
110
- def plural_options(switch)
111
- standard_option(switch.to_s, switch.as_key) +
112
- standard_option(switch.to_s, switch.as_plural_key)
110
+ def plural_options(name)
111
+ standard_option(name.to_s, name.as_key) +
112
+ standard_option(name.to_s, name.as_plural_key)
113
113
  end
114
114
  end
115
115
  end
@@ -1,12 +1,16 @@
1
1
  module RubyTerraform
2
2
  module Options
3
- class Switch
4
- def initialize(switch)
5
- @switch_without_prefix = switch[0] == '-' ? switch[1..] : switch
3
+ class Name
4
+ def initialize(name)
5
+ @name = name
6
+ end
7
+
8
+ def without_prefix
9
+ @name[0] == '-' ? @name[1..] : @name
6
10
  end
7
11
 
8
12
  def to_s
9
- "-#{switch_without_prefix}"
13
+ "-#{without_prefix}"
10
14
  end
11
15
 
12
16
  def as_key
@@ -31,10 +35,8 @@ module RubyTerraform
31
35
 
32
36
  private
33
37
 
34
- attr_reader :switch_without_prefix
35
-
36
38
  def snake_case
37
- switch_without_prefix.gsub('-', '_')
39
+ without_prefix.gsub('-', '_')
38
40
  end
39
41
  end
40
42
  end
@@ -0,0 +1,24 @@
1
+ module RubyTerraform
2
+ module Options
3
+ module Types
4
+ class Base
5
+ def initialize(name, value)
6
+ @name = name
7
+ coerce_value(value)
8
+ end
9
+
10
+ def apply(_builder)
11
+ raise 'not implemented'
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :name, :value
17
+
18
+ def coerce_value(value)
19
+ @value = value
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'base'
2
+ require_relative '../values/boolean'
3
+
4
+ module RubyTerraform
5
+ module Options
6
+ module Types
7
+ class Boolean < Base
8
+ include Values::Boolean
9
+
10
+ def apply(builder)
11
+ builder.with_option(name, value)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'base'
2
+ require_relative '../values/boolean'
3
+
4
+ module RubyTerraform
5
+ module Options
6
+ module Types
7
+ class Flag < Base
8
+ include Values::Boolean
9
+
10
+ def apply(builder)
11
+ value ? builder.with_flag(name) : builder
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,41 @@
1
+ require 'json'
2
+
3
+ require_relative 'base'
4
+
5
+ module RubyTerraform
6
+ module Options
7
+ module Types
8
+ class Standard < Base
9
+ def apply(builder)
10
+ if value.respond_to?(:keys)
11
+ apply_hash(builder)
12
+ elsif value.respond_to?(:each)
13
+ apply_array(builder)
14
+ else
15
+ builder.with_option(name, value)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def apply_hash(builder)
22
+ builder.with_repeated_option(
23
+ name,
24
+ value.map do |hash_key, hash_value|
25
+ "'#{hash_key}=#{as_string(hash_value)}'"
26
+ end,
27
+ separator: ' '
28
+ )
29
+ end
30
+
31
+ def apply_array(builder)
32
+ builder.with_repeated_option(name, value)
33
+ end
34
+
35
+ def as_string(value)
36
+ value.is_a?(String) ? value : JSON.generate(value)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyTerraform
2
- VERSION = '0.65.0.pre.6'.freeze
2
+ VERSION = '0.65.0.pre.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.0.pre.6
4
+ version: 0.65.0.pre.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
@@ -256,12 +256,13 @@ files:
256
256
  - lib/ruby_terraform/commands/workspace.rb
257
257
  - lib/ruby_terraform/errors.rb
258
258
  - lib/ruby_terraform/errors/execution_error.rb
259
- - lib/ruby_terraform/options/base.rb
260
- - lib/ruby_terraform/options/boolean.rb
259
+ - lib/ruby_terraform/options.rb
261
260
  - lib/ruby_terraform/options/factory.rb
262
- - lib/ruby_terraform/options/flag.rb
263
- - lib/ruby_terraform/options/standard.rb
264
- - lib/ruby_terraform/options/switch.rb
261
+ - lib/ruby_terraform/options/name.rb
262
+ - lib/ruby_terraform/options/types/base.rb
263
+ - lib/ruby_terraform/options/types/boolean.rb
264
+ - lib/ruby_terraform/options/types/flag.rb
265
+ - lib/ruby_terraform/options/types/standard.rb
265
266
  - lib/ruby_terraform/options/values/boolean.rb
266
267
  - lib/ruby_terraform/output.rb
267
268
  - lib/ruby_terraform/version.rb
@@ -1,22 +0,0 @@
1
- module RubyTerraform
2
- module Options
3
- class Base
4
- def initialize(switch, value)
5
- @switch = switch
6
- coerce_value(value)
7
- end
8
-
9
- def apply(_builder)
10
- raise 'not implemented'
11
- end
12
-
13
- private
14
-
15
- attr_reader :switch, :value
16
-
17
- def coerce_value(value)
18
- @value = value
19
- end
20
- end
21
- end
22
- end
@@ -1,14 +0,0 @@
1
- require_relative 'base'
2
- require_relative 'values/boolean'
3
-
4
- module RubyTerraform
5
- module Options
6
- class Boolean < Base
7
- include Values::Boolean
8
-
9
- def apply(builder)
10
- builder.with_option(switch, value)
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require_relative 'base'
2
- require_relative 'values/boolean'
3
-
4
- module RubyTerraform
5
- module Options
6
- class Flag < Base
7
- include Values::Boolean
8
-
9
- def apply(builder)
10
- value ? builder.with_flag(switch) : builder
11
- end
12
- end
13
- end
14
- end
@@ -1,39 +0,0 @@
1
- require 'json'
2
-
3
- require_relative 'base'
4
-
5
- module RubyTerraform
6
- module Options
7
- class Standard < Base
8
- def apply(builder)
9
- if value.respond_to?(:keys)
10
- apply_hash(builder)
11
- elsif value.respond_to?(:each)
12
- apply_array(builder)
13
- else
14
- builder.with_option(switch, value)
15
- end
16
- end
17
-
18
- private
19
-
20
- def apply_hash(builder)
21
- builder.with_repeated_option(
22
- switch,
23
- value.map do |hash_key, hash_value|
24
- "'#{hash_key}=#{as_string(hash_value)}'"
25
- end,
26
- separator: ' '
27
- )
28
- end
29
-
30
- def apply_array(builder)
31
- builder.with_repeated_option(switch, value)
32
- end
33
-
34
- def as_string(value)
35
- value.is_a?(String) ? value : JSON.generate(value)
36
- end
37
- end
38
- end
39
- end