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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -15
  3. data/README.md +148 -397
  4. data/Rakefile +25 -0
  5. data/lib/ruby_terraform.rb +707 -45
  6. data/lib/ruby_terraform/commands.rb +0 -2
  7. data/lib/ruby_terraform/commands/apply.rb +7 -7
  8. data/lib/ruby_terraform/commands/base.rb +4 -1
  9. data/lib/ruby_terraform/commands/destroy.rb +6 -5
  10. data/lib/ruby_terraform/commands/force_unlock.rb +6 -4
  11. data/lib/ruby_terraform/commands/format.rb +8 -4
  12. data/lib/ruby_terraform/commands/get.rb +6 -4
  13. data/lib/ruby_terraform/commands/graph.rb +11 -3
  14. data/lib/ruby_terraform/commands/import.rb +8 -7
  15. data/lib/ruby_terraform/commands/init.rb +16 -6
  16. data/lib/ruby_terraform/commands/login.rb +2 -2
  17. data/lib/ruby_terraform/commands/logout.rb +2 -2
  18. data/lib/ruby_terraform/commands/output.rb +2 -2
  19. data/lib/ruby_terraform/commands/plan.rb +6 -3
  20. data/lib/ruby_terraform/commands/providers.rb +9 -3
  21. data/lib/ruby_terraform/commands/providers_lock.rb +10 -7
  22. data/lib/ruby_terraform/commands/providers_mirror.rb +3 -3
  23. data/lib/ruby_terraform/commands/providers_schema.rb +21 -2
  24. data/lib/ruby_terraform/commands/refresh.rb +70 -3
  25. data/lib/ruby_terraform/commands/show.rb +26 -3
  26. data/lib/ruby_terraform/commands/state_list.rb +54 -3
  27. data/lib/ruby_terraform/commands/state_move.rb +64 -6
  28. data/lib/ruby_terraform/commands/state_pull.rb +24 -2
  29. data/lib/ruby_terraform/commands/state_push.rb +49 -3
  30. data/lib/ruby_terraform/commands/state_remove.rb +55 -7
  31. data/lib/ruby_terraform/commands/state_replace_provider.rb +39 -6
  32. data/lib/ruby_terraform/commands/state_show.rb +26 -2
  33. data/lib/ruby_terraform/commands/taint.rb +63 -2
  34. data/lib/ruby_terraform/commands/untaint.rb +55 -2
  35. data/lib/ruby_terraform/commands/validate.rb +51 -6
  36. data/lib/ruby_terraform/commands/workspace_delete.rb +29 -7
  37. data/lib/ruby_terraform/commands/workspace_list.rb +21 -6
  38. data/lib/ruby_terraform/commands/workspace_new.rb +28 -7
  39. data/lib/ruby_terraform/commands/workspace_select.rb +23 -7
  40. data/lib/ruby_terraform/commands/workspace_show.rb +17 -2
  41. data/lib/ruby_terraform/options.rb +1 -1
  42. data/lib/ruby_terraform/options/definition.rb +3 -1
  43. data/lib/ruby_terraform/options/definitions.rb +12 -3
  44. data/lib/ruby_terraform/options/{common.rb → global.rb} +1 -1
  45. data/lib/ruby_terraform/options/types.rb +0 -1
  46. data/lib/ruby_terraform/options/types/flag.rb +8 -4
  47. data/lib/ruby_terraform/options/types/standard.rb +20 -6
  48. data/lib/ruby_terraform/version.rb +1 -1
  49. data/ruby_terraform.gemspec +2 -2
  50. metadata +9 -12
  51. data/lib/ruby_terraform/commands/clean.rb +0 -26
  52. data/lib/ruby_terraform/commands/remote_config.rb +0 -25
  53. data/lib/ruby_terraform/options/types/base.rb +0 -19
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'commands/apply'
4
- require_relative 'commands/clean'
5
4
  require_relative 'commands/destroy'
6
5
  require_relative 'commands/force_unlock'
7
6
  require_relative 'commands/format'
@@ -18,7 +17,6 @@ require_relative 'commands/providers_lock'
18
17
  require_relative 'commands/providers_mirror'
19
18
  require_relative 'commands/providers_schema'
20
19
  require_relative 'commands/refresh'
21
- require_relative 'commands/remote_config'
22
20
  require_relative 'commands/show'
23
21
  require_relative 'commands/state_list'
24
22
  require_relative 'commands/state_move'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -19,10 +19,10 @@ module RubyTerraform
19
19
  # When executing an instance of {Apply} via {#execute}, the following
20
20
  # options are supported:
21
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.
22
+ # * +:directory+: the path to a directory containing terraform
23
+ # configuration (deprecated in terraform 0.14, removed in terraform 0.15,
24
+ # use +:chdir+ instead).
25
+ # * +:plan+: the path to a pre-computed plan to be applied.
26
26
  # * +:chdir+: the path of a working directory to switch to before executing
27
27
  # the given subcommand.
28
28
  # * +:auto_approve+: if +true+, skips interactive approval of the generated
@@ -71,7 +71,7 @@ module RubyTerraform
71
71
  # })
72
72
  #
73
73
  class Apply < Base
74
- include RubyTerraform::Options::Common
74
+ include RubyTerraform::Options::Global
75
75
 
76
76
  # @!visibility private
77
77
  def subcommands
@@ -83,12 +83,12 @@ module RubyTerraform
83
83
  # @!visibility private
84
84
  def options
85
85
  %w[
86
+ -auto-approve
86
87
  -backup
87
88
  -compact-warnings
88
89
  -lock
89
90
  -lock-timeout
90
91
  -input
91
- -auto-approve
92
92
  -no-color
93
93
  -parallelism
94
94
  -refresh
@@ -24,6 +24,9 @@ module RubyTerraform
24
24
 
25
25
  # Executes the command instance.
26
26
  #
27
+ # @param [Hash<String, Object>] parameters The parameters used to
28
+ # invoke the command. See subclass documentation for details of
29
+ # supported options.
27
30
  def execute(parameters = {})
28
31
  do_before(parameters)
29
32
  build_and_execute_command(parameters)
@@ -68,7 +71,7 @@ module RubyTerraform
68
71
  .with_option_separator('=')
69
72
  .with_appliables(@options.resolve(options, parameters))
70
73
  .with_subcommands(subcommands)
71
- .with_arguments(arguments(parameters)).build
74
+ .with_arguments(arguments(parameters).compact.flatten).build
72
75
  end
73
76
 
74
77
  def resolve_parameters(parameters)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -13,8 +13,9 @@ module RubyTerraform
13
13
  # When executing an instance of {Destroy} via {#execute}, the following
14
14
  # options are supported:
15
15
  #
16
- # * +:directory+: the directory containing terraform configuration;
17
- # required.
16
+ # * +:directory+: the path to a directory containing terraform
17
+ # configuration (deprecated in terraform 0.14, removed in terraform 0.15,
18
+ # use +:chdir+ instead).
18
19
  # * +:chdir+: the path of a working directory to switch to before executing
19
20
  # the given subcommand.
20
21
  # * +:auto_approve+: if +true+, skips interactive approval before
@@ -63,7 +64,7 @@ module RubyTerraform
63
64
  # })
64
65
  #
65
66
  class Destroy < Base
66
- include RubyTerraform::Options::Common
67
+ include RubyTerraform::Options::Global
67
68
 
68
69
  # @!visibility private
69
70
  def subcommands
@@ -75,12 +76,12 @@ module RubyTerraform
75
76
  # @!visibility private
76
77
  def options
77
78
  %w[
79
+ -auto-approve
78
80
  -backup
79
81
  -compact-warnings
80
82
  -lock
81
83
  -lock-timeout
82
84
  -input
83
- -auto-approve
84
85
  -no-color
85
86
  -parallelism
86
87
  -refresh
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -20,6 +20,9 @@ module RubyTerraform
20
20
  #
21
21
  # * +:lock_id+: the lock ID output when attempting an operation that failed
22
22
  # due to a lock; required.
23
+ # * +:directory+: the path to a directory containing terraform
24
+ # configuration (deprecated in terraform 0.14, removed in terraform 0.15,
25
+ # use +:chdir+ instead).
23
26
  # * +:chdir+: the path of a working directory to switch to before executing
24
27
  # the given subcommand.
25
28
  # * +:force+: If +true+, does not ask for input for unlock confirmation;
@@ -30,7 +33,7 @@ module RubyTerraform
30
33
  # lock_id: '50e844a7-ebb0-fcfd-da85-5cce5bd1ec90')
31
34
  #
32
35
  class ForceUnlock < Base
33
- include RubyTerraform::Options::Common
36
+ include RubyTerraform::Options::Global
34
37
 
35
38
  # @!visibility private
36
39
  def subcommands
@@ -43,9 +46,8 @@ module RubyTerraform
43
46
  end
44
47
 
45
48
  # @!visibility private
46
- # @todo Add directory option.
47
49
  def arguments(parameters)
48
- [parameters[:lock_id]]
50
+ [parameters[:lock_id], parameters[:directory]]
49
51
  end
50
52
  end
51
53
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -21,7 +21,9 @@ module RubyTerraform
21
21
  # When executing an instance of {Format} via {#execute}, the following
22
22
  # options are supported:
23
23
  #
24
- # * +:directory+: the directory containing terraform configuration.
24
+ # * +:directory+: the path to a directory containing terraform
25
+ # configuration (deprecated in terraform 0.14, removed in terraform 0.15,
26
+ # use +:chdir+ instead).
25
27
  # * +:chdir+: the path of a working directory to switch to before executing
26
28
  # the given subcommand.
27
29
  # * +:list+: If +true+, lists files whose formatting differs; defaults to
@@ -33,6 +35,8 @@ module RubyTerraform
33
35
  # * +:check+: If +true+, checks if the input is formatted; if any input is
34
36
  # not properly formatted, an {RubyTerraform::Errors::ExecutionError} will
35
37
  # be thrown; defaults to +false+.
38
+ # * +:no_color+: whether or not the output from the command should be in
39
+ # color; defaults to +false+.
36
40
  # * +:recursive+: If +true+, also processes files in subdirectories;
37
41
  # defaults to +false+ such that only the provided +:directory+ is
38
42
  # processed.
@@ -41,7 +45,7 @@ module RubyTerraform
41
45
  # RubyTerraform::Commands::Format.new.execute(
42
46
  # directory: 'infra/networking')
43
47
  class Format < Base
44
- include RubyTerraform::Options::Common
48
+ include RubyTerraform::Options::Global
45
49
 
46
50
  # @!visibility private
47
51
  def subcommands
@@ -49,13 +53,13 @@ module RubyTerraform
49
53
  end
50
54
 
51
55
  # @!visibility private
52
- # @todo Add no_color option.
53
56
  def options
54
57
  %w[
55
58
  -list
56
59
  -write
57
60
  -diff
58
61
  -check
62
+ -no-color
59
63
  -recursive
60
64
  ] + super
61
65
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -21,8 +21,9 @@ module RubyTerraform
21
21
  # When executing an instance of {Get} via {#execute}, the following options
22
22
  # are supported:
23
23
  #
24
- # * +:directory+: the directory containing terraform configuration;
25
- # required.
24
+ # * +:directory+: the path to a directory containing terraform
25
+ # configuration (deprecated in terraform 0.14, removed in terraform 0.15,
26
+ # use +:chdir+ instead).
26
27
  # * +:chdir+: the path of a working directory to switch to before executing
27
28
  # the given subcommand.
28
29
  # * +:update+: if +true+, checks already-downloaded modules for available
@@ -33,8 +34,9 @@ module RubyTerraform
33
34
  # @example Basic Invocation
34
35
  # RubyTerraform::Commands::Get.new.execute(
35
36
  # directory: 'infra/networking')
37
+ #
36
38
  class Get < Base
37
- include RubyTerraform::Options::Common
39
+ include RubyTerraform::Options::Global
38
40
 
39
41
  # @!visibility private
40
42
  def subcommands
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -24,6 +24,9 @@ module RubyTerraform
24
24
  # When executing an instance of {Graph} via {#execute}, the following
25
25
  # options are supported:
26
26
  #
27
+ # * +:directory+: the path to a directory containing terraform
28
+ # configuration (deprecated in terraform 0.14, removed in terraform 0.15,
29
+ # use +:chdir+ instead).
27
30
  # * +:chdir+: the path of a working directory to switch to before executing
28
31
  # the given subcommand.
29
32
  # * +:plan+: render the graph using the specified plan file instead of the
@@ -41,7 +44,7 @@ module RubyTerraform
41
44
  # RubyTerraform::Commands::Graph.new.execute
42
45
  #
43
46
  class Graph < Base
44
- include RubyTerraform::Options::Common
47
+ include RubyTerraform::Options::Global
45
48
 
46
49
  # @!visibility private
47
50
  def subcommands
@@ -49,14 +52,19 @@ module RubyTerraform
49
52
  end
50
53
 
51
54
  # @!visibility private
52
- # @todo Add plan option.
53
55
  def options
54
56
  %w[
57
+ -plan
55
58
  -draw-cycles
56
59
  -type
57
60
  -module-depth
58
61
  ] + super
59
62
  end
63
+
64
+ # @!visibility private
65
+ def arguments(parameters)
66
+ [parameters[:directory]]
67
+ end
60
68
  end
61
69
  end
62
70
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -36,10 +36,9 @@ module RubyTerraform
36
36
  # When executing an instance of {Import} via {#execute}, the following
37
37
  # options are supported:
38
38
  #
39
- # * +:directory+: the path to a directory of terraform configuration files
40
- # to use to configure the provider; defaults to the current directory; if
41
- # no config files are present, they must be provided via the input prompts
42
- # or env vars.
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).
43
42
  # * +:address+: the address to import the resource to; required.
44
43
  # * +:id+: the resource-specific ID identifying the resource being imported;
45
44
  # required.
@@ -48,6 +47,8 @@ module RubyTerraform
48
47
  # * +:backup+: (legacy) the path to backup the existing state file before
49
48
  # modifying; defaults to the +:state_out+ path with +".backup"+ extension;
50
49
  # set +:no_backup+ to +true+ to skip backups entirely.
50
+ # * +:allow_missing_config+: whether or not to allow import when no resource
51
+ # configuration block exists; defaults to +false+.
51
52
  # * +:input+: when +false+, will not ask for input for variables not
52
53
  # directly set; defaults to +true+.
53
54
  # * +:lock+: when +true+, locks the state file when locking is supported;
@@ -90,7 +91,7 @@ module RubyTerraform
90
91
  # })
91
92
  #
92
93
  class Import < Base
93
- include RubyTerraform::Options::Common
94
+ include RubyTerraform::Options::Global
94
95
 
95
96
  # @!visibility private
96
97
  def subcommands
@@ -100,10 +101,10 @@ module RubyTerraform
100
101
  # rubocop:disable Metrics/MethodLength
101
102
 
102
103
  # @!visibility private
103
- # @todo Add allow_missing_config option.
104
104
  def options
105
105
  %w[
106
106
  -config
107
+ -allow-missing-config
107
108
  -backup
108
109
  -input
109
110
  -lock
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -24,7 +24,9 @@ module RubyTerraform
24
24
  # When executing an instance of {Init} via {#execute}, the following
25
25
  # options are supported:
26
26
  #
27
- # * +:path+: the path to initialize; defaults to the current directory.
27
+ # * +:path+: the path to initialize; defaults to the current directory
28
+ # (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
29
+ # instead).
28
30
  # * +:chdir+: the path of a working directory to switch to before executing
29
31
  # the given subcommand.
30
32
  # * +:backend+: whether or not to configure the backend for this
@@ -51,7 +53,14 @@ module RubyTerraform
51
53
  # color; defaults to +false+.
52
54
  # * +:plugin_dir+: the path to a directory containing plugin binaries; this
53
55
  # overrides all default search paths for plugins, and prevents the
54
- # automatic installation of plugins.
56
+ # automatic installation of plugins; if both +:plugin_dir+ and
57
+ # +:plugin_dirs+ are provided, all plugin directories will be passed to
58
+ # Terraform.
59
+ # * +:plugin_dirs+: an array of paths to directories containing plugin
60
+ # binaries; this overrides all default search paths for plugins, and
61
+ # prevents the automatic installation of plugins; if both +:plugin_dir+
62
+ # and +:plugin_dirs+ are provided, all plugin directories will be passed
63
+ # to Terraform.
55
64
  # * +:reconfigure+: if +true+, reconfigures the backend, ignoring any saved
56
65
  # configuration; defaults to +false+.
57
66
  # * +:upgrade+: if +true+, when installing modules or plugins, ignores
@@ -60,6 +69,8 @@ module RubyTerraform
60
69
  # * +:verify_plugins+: whether or not to verify plugins for this
61
70
  # configuration; defaults to +true+ (deprecated, removed in terraform
62
71
  # 0.15).
72
+ # * +:lockfile+: sets a dependency lockfile mode; currently only "readonly"
73
+ # is valid.
63
74
  #
64
75
  # @example Basic Invocation
65
76
  # RubyTerraform::Commands::Init.new.execute(
@@ -67,7 +78,7 @@ module RubyTerraform
67
78
  # path: 'infra/module')
68
79
  #
69
80
  class Init < Base
70
- include RubyTerraform::Options::Common
81
+ include RubyTerraform::Options::Global
71
82
 
72
83
  # @!visibility private
73
84
  def subcommands
@@ -77,8 +88,6 @@ module RubyTerraform
77
88
  # rubocop:disable Metrics/MethodLength
78
89
 
79
90
  # @!visibility private
80
- # @todo Add lockfile option.
81
- # @todo Make plugin_dir option plural
82
91
  def options
83
92
  %w[
84
93
  -backend
@@ -95,6 +104,7 @@ module RubyTerraform
95
104
  -reconfigure
96
105
  -upgrade
97
106
  -verify-plugins
107
+ -lockfile
98
108
  ] + super
99
109
  end
100
110
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -28,7 +28,7 @@ module RubyTerraform
28
28
  # RubyTerraform::Commands::Login.new.execute
29
29
  #
30
30
  class Login < Base
31
- include RubyTerraform::Options::Common
31
+ include RubyTerraform::Options::Global
32
32
 
33
33
  # @!visibility private
34
34
  def subcommands
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
@@ -25,7 +25,7 @@ module RubyTerraform
25
25
  # RubyTerraform::Commands::Logout.new.execute
26
26
  #
27
27
  class Logout < Base
28
- include RubyTerraform::Options::Common
28
+ include RubyTerraform::Options::Global
29
29
 
30
30
  # @!visibility private
31
31
  def subcommands