ruby-terraform 0.65.0.pre.13 → 0.65.0.pre.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67cc10d1c813e81407ee1fde4952f587dfaeb97a9da6eacd921e0948ff274b37
4
- data.tar.gz: 34cc711d0e383c6e4b745434d50a66fb11629d8533b9226229b1a0ab051909a3
3
+ metadata.gz: 897da01f6ce70cf4c6f38c95d50a49c620da02e78078c1da7a14daa2f7f15f11
4
+ data.tar.gz: 476f49771b6acd39233c7b36987b397556ada57fc5bf5d4eeccec42bfe414ea0
5
5
  SHA512:
6
- metadata.gz: ef66d6f1e646abbe98fb68ccf46d67b672ba3b0be23ed8e94f14f6c235d78099db4973493d4743a5fc0c03dc077322cb78675c34865c915f2707748e981f392a
7
- data.tar.gz: 7136d3958da6a0f4a375c41eb1a306aa4f06cddeb865ff2e1e953e1b1b26df5b464890413e7b539dbfd1931c970fcf04fcc050d9996337da17d131a3b3c0dee4
6
+ metadata.gz: 98e74c44146a22196085aaa288c9ac93cf94ebb17aacd9e16473de232c0e9e87f59682df2978c8902f561f2e4ae040e57398f550c7a3fc359fba80e184615fb9
7
+ data.tar.gz: 98f3870cf241284aa5197012e72d7132e6e5a52f9e70724b07a65231c8605a7020aaa064b9920240d4e02585df0cd05cd664c411113589e79fc288cc5b24845c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.65.0.pre.13)
4
+ ruby-terraform (0.65.0.pre.14)
5
5
  immutable-struct (>= 2.4)
6
6
  lino (>= 2.5)
7
7
 
@@ -22,14 +22,18 @@ GEM
22
22
  concurrent-ruby (1.1.8)
23
23
  diff-lcs (1.4.4)
24
24
  docile (1.3.5)
25
- excon (0.79.0)
25
+ excon (0.80.1)
26
26
  faker (2.17.0)
27
27
  i18n (>= 1.6, < 2)
28
- faraday (1.3.0)
28
+ faraday (1.4.1)
29
+ faraday-excon (~> 1.1)
29
30
  faraday-net_http (~> 1.0)
31
+ faraday-net_http_persistent (~> 1.1)
30
32
  multipart-post (>= 1.2, < 3)
31
- ruby2_keywords
33
+ ruby2_keywords (>= 0.0.4)
34
+ faraday-excon (1.1.0)
32
35
  faraday-net_http (1.0.1)
36
+ faraday-net_http_persistent (1.1.0)
33
37
  ffi (1.15.0)
34
38
  formatador (0.2.5)
35
39
  gem-release (2.2.1)
@@ -117,7 +121,7 @@ GEM
117
121
  diff-lcs (>= 1.2.0, < 2.0)
118
122
  rspec-support (~> 3.10.0)
119
123
  rspec-support (3.10.2)
120
- rubocop (1.12.1)
124
+ rubocop (1.13.0)
121
125
  parallel (~> 1.10)
122
126
  parser (>= 3.0.0.0)
123
127
  rainbow (>= 2.2.2, < 4.0)
@@ -152,6 +156,7 @@ GEM
152
156
  tzinfo (2.0.4)
153
157
  concurrent-ruby (~> 1.0)
154
158
  unicode-display_width (2.0.0)
159
+ yard (0.9.26)
155
160
  zeitwerk (2.4.2)
156
161
 
157
162
  PLATFORMS
@@ -174,6 +179,7 @@ DEPENDENCIES
174
179
  rubocop-rspec (~> 2.2)
175
180
  ruby-terraform!
176
181
  simplecov (~> 0.21)
182
+ yard (~> 0.9)
177
183
 
178
184
  BUNDLED WITH
179
185
  2.2.16
@@ -24,8 +24,80 @@ module RubyTerraform
24
24
  end
25
25
 
26
26
  module ClassMethods
27
+ # Invokes the +terraform apply+ command which creates or updates
28
+ # infrastructure according to terraform configuration files in the provided
29
+ # directory.
30
+ #
31
+ # By default, terraform will generate a new plan and present it for approval
32
+ # before taking any action. Alternatively, the command accepts a plan file
33
+ # created by a previous invocation, in which case terraform will take the
34
+ # actions described in that plan without any confirmation prompt.
35
+ #
36
+ # @param parameters The parameters used to invoke the command
37
+ # @option parameters [String] :directory The directory containing terraform
38
+ # configuration; required unless +:plan+ is provided.
39
+ # @option parameters [String] :plan The path to a pre-computed plan to be
40
+ # applied; required unless +:directory+ is provided.
41
+ # @option parameters [Boolean] :auto_approve (false) If +true+, skips
42
+ # interactive approval of the generated plan before applying.
43
+ # @option parameters [String] :backup The path to backup the existing state
44
+ # file before modifying; defaults to the +:state_out+ path with
45
+ # +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
46
+ # entirely.
47
+ # @option parameters [String] :chdir The path of a working directory to
48
+ # switch to before executing the given subcommand.
49
+ # @option parameters [Boolean] :compact_warnings (false) When +true+, if
50
+ # terraform produces any warnings that are not accompanied by errors,
51
+ # they are shown in a more compact form that includes only the summary
52
+ # messages.
53
+ # @option parameters [Boolean] :input (true) When +false+, will not ask for
54
+ # input for variables not directly set.
55
+ # @option parameters [Boolean] :lock (true) When +true+, locks the state
56
+ # file when locking is supported; when +false+, does not lock the state
57
+ # file.
58
+ # @option parameters [String] :lock_timeout ("0s") The duration to retry a
59
+ # state lock.
60
+ # @option parameters [Boolean] :no_backup (false) When +true+, no backup
61
+ # file will be written.
62
+ # @option parameters [Boolean] :no_color (false) Whether or not the output
63
+ # from the command should be in color.
64
+ # @option parameters [Integer] :parallelism (10) The number of parallel
65
+ # resource operations.
66
+ # @option parameters [Boolean] :refresh (true) When +true+, updates state
67
+ # prior to checking for differences; when +false+ uses locally available
68
+ # state; this has no effect when +:plan+ is provided.
69
+ # @option parameters [String] :state ("terraform.tfstate") The path to the
70
+ # state file from which to read state and in which to store state (unless
71
+ # +:state_out+ is specified).
72
+ # @option parameters [String] :state_out The path to write state to that is
73
+ # different than +:state+; this can be used to preserve the old state.
74
+ # @option parameters [String] :target The address of a resource to target;
75
+ # if both +:target+ and +:targets+ are provided, all targets will be
76
+ # passed to terraform.
77
+ # @option parameters [Array<String>] :targets An array of resource addresses
78
+ # to target; if both +:target+ and +:targets+ are provided, all targets
79
+ # will be passed to terraform.
80
+ # @option parameters [Hash<String, Object>] :vars A map of variables to be
81
+ # passed to the terraform configuration.
82
+ # @option parameters [String] :var_file The path to a terraform var file;
83
+ # if both +:var_file+ and +:var_files+ are provided, all var files will be
84
+ # passed to terraform.
85
+ # @option parameters [Array<String>] :var_files An array of paths to
86
+ # terraform var files; if both +:var_file+ and +:var_files+ are provided,
87
+ # all var files will be passed to terraform.
88
+ #
89
+ # @example Basic Invocation
90
+ # RubyTerraform.apply(
91
+ # directory: 'infra/networking',
92
+ # vars: {
93
+ # region: 'eu-central'
94
+ # })
95
+ #
96
+ def apply(parameters = {})
97
+ exec(RubyTerraform::Commands::Apply, parameters)
98
+ end
99
+
27
100
  {
28
- apply: RubyTerraform::Commands::Apply,
29
101
  clean: RubyTerraform::Commands::Clean,
30
102
  destroy: RubyTerraform::Commands::Destroy,
31
103
  format: RubyTerraform::Commands::Format,
@@ -5,14 +5,83 @@ require_relative '../options/common'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform apply+ command which creates or updates
9
+ # infrastructure according to terraform configuration files in the provided
10
+ # directory.
11
+ #
12
+ # By default, terraform will generate a new plan and present it for approval
13
+ # before taking any action. Alternatively, the command accepts a plan file
14
+ # created by a previous invocation, in which case terraform will take the
15
+ # actions described in that plan without any confirmation prompt.
16
+ #
17
+ # For options accepted on construction, see {#initialize}.
18
+ #
19
+ # When executing an instance of {Apply} via {#execute}, the following
20
+ # options are supported:
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.
26
+ # * +:auto_approve+: if +true+, skips interactive approval of the generated
27
+ # plan before applying; defaults to +false+.
28
+ # * +:backup+: the path to backup the existing state file before modifying;
29
+ # defaults to the +:state_out+ path with +".backup"+ extension; set
30
+ # +:no_backup+ to +true+ to skip backups entirely.
31
+ # * +:chdir+: the path of a working directory to switch to before executing
32
+ # the given subcommand.
33
+ # * +:compact_warnings+: when +true+, if terraform produces any warnings
34
+ # that are not accompanied by errors, they are shown in a more compact
35
+ # form that includes only the summary messages; defaults to +false+.
36
+ # * +:input+: when +false+, will not ask for input for variables not
37
+ # directly set; defaults to +true+.
38
+ # * +:lock+: when +true+, locks the state file when locking is supported;
39
+ # when +false+, does not lock the state file; defaults to +true+.
40
+ # * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
41
+ # * +:no_backup+: when +true+, no backup file will be written; defaults to
42
+ # +false+.
43
+ # * +:no_color+: whether or not the output from the command should be in
44
+ # color; defaults to +false+.
45
+ # * +:parallelism+: the number of parallel resource operations; defaults to
46
+ # +10+.
47
+ # * +:refresh+: when +true+, updates state prior to checking for
48
+ # differences; when +false+ uses locally available state; defaults to
49
+ # +true+; this has no effect when +:plan+ is provided.
50
+ # * +:state+: the path to the state file from which to read state and in
51
+ # which to store state (unless +:state_out+ is specified); defaults to
52
+ # +"terraform.tfstate"+.
53
+ # * +:state_out+: the path to write state to that is different than
54
+ # +:state+; this can be used to preserve the old state.
55
+ # * +:target+: the address of a resource to target; if both +:target+ and
56
+ # +:targets+ are provided, all targets will be passed to terraform.
57
+ # * +:targets+: an array of resource addresses to target; if both +:target+
58
+ # and +:targets+ are provided, all targets will be passed to terraform.
59
+ # * +:vars+: a map of variables to be passed to the terraform configuration.
60
+ # * +:var_file+: the path to a terraform var file; if both +:var_file+ and
61
+ # +:var_files+ are provided, all var files will be passed to terraform.
62
+ # * +:var_files+: an array of paths to terraform var files; if both
63
+ # +:var_file+ and +:var_files+ are provided, all var files will be passed
64
+ # to terraform.
65
+ #
66
+ # @example Basic Invocation
67
+ # RubyTerraform::Commands::Apply.new.execute(
68
+ # directory: 'infra/networking',
69
+ # vars: {
70
+ # region: 'eu-central'
71
+ # })
72
+ #
8
73
  class Apply < Base
9
74
  include RubyTerraform::Options::Common
10
75
 
76
+ # @!visibility private
11
77
  def subcommands
12
78
  %w[apply]
13
79
  end
14
80
 
15
- def options # rubocop:disable Metrics/MethodLength
81
+ # rubocop:disable Metrics/MethodLength
82
+
83
+ # @!visibility private
84
+ def options
16
85
  %w[
17
86
  -backup
18
87
  -compact-warnings
@@ -31,14 +100,19 @@ module RubyTerraform
31
100
  ] + super
32
101
  end
33
102
 
103
+ # rubocop:enable Metrics/MethodLength
104
+
105
+ # @!visibility private
34
106
  def arguments(parameters)
35
107
  [parameters[:plan] || parameters[:directory]]
36
108
  end
37
109
 
110
+ # @!visibility private
38
111
  def parameter_defaults(_parameters)
39
112
  { vars: {}, var_files: [], targets: [] }
40
113
  end
41
114
 
115
+ # @!visibility private
42
116
  def parameter_overrides(parameters)
43
117
  { backup: parameters[:no_backup] ? '-' : parameters[:backup] }
44
118
  end
@@ -7,7 +7,11 @@ require_relative '../errors'
7
7
  module RubyTerraform
8
8
  module Commands
9
9
  class Base
10
- def initialize(**opts) # rubocop:disable Metrics/AbcSize
10
+ # rubocop:disable Metrics/AbcSize
11
+
12
+ # Constructs an instance of the command.
13
+ #
14
+ def initialize(**opts)
11
15
  @binary = opts[:binary] || RubyTerraform.configuration.binary
12
16
  @logger = opts[:logger] || RubyTerraform.configuration.logger
13
17
  @options = opts[:options] || RubyTerraform.configuration.options
@@ -16,6 +20,10 @@ module RubyTerraform
16
20
  @stderr = opts[:stderr] || RubyTerraform.configuration.stderr
17
21
  end
18
22
 
23
+ # rubocop:enable Metrics/AbcSize
24
+
25
+ # Executes the command instance.
26
+ #
19
27
  def execute(parameters = {})
20
28
  do_before(parameters)
21
29
  build_and_execute_command(parameters)
@@ -3,6 +3,7 @@
3
3
  module RubyTerraform
4
4
  module Options
5
5
  module Common
6
+ # @!visibility private
6
7
  def options
7
8
  %w[-chdir]
8
9
  end
@@ -18,7 +18,8 @@ module RubyTerraform
18
18
  :separator,
19
19
  :repeatable?
20
20
  )
21
- def initialize(opts) # rubocop:disable Metrics/MethodLength
21
+ # rubocop:disable Metrics/MethodLength
22
+ def initialize(opts)
22
23
  raise 'Missing name.' unless opts[:name]
23
24
 
24
25
  super(
@@ -35,6 +36,7 @@ module RubyTerraform
35
36
  .merge(opts[:override_keys] || {})
36
37
  )
37
38
  end
39
+ # rubocop:enable Metrics/MethodLength
38
40
 
39
41
  def matches?(name)
40
42
  @name == Name.new(name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyTerraform
4
- VERSION = '0.65.0.pre.13'
4
+ VERSION = '0.65.0.pre.14'
5
5
  end
@@ -56,4 +56,5 @@ Gem::Specification.new do |spec|
56
56
  spec.add_development_dependency 'rubocop-rake', '~> 0.5'
57
57
  spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
58
58
  spec.add_development_dependency 'simplecov', '~> 0.21'
59
+ spec.add_development_dependency 'yard', '~> 0.9'
59
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.0.pre.13
4
+ version: 0.65.0.pre.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-14 00:00:00.000000000 Z
11
+ date: 2021-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: immutable-struct
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0.21'
251
+ - !ruby/object:Gem::Dependency
252
+ name: yard
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '0.9'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '0.9'
251
265
  description: Wraps the Terraform CLI so that Terraform can be invoked from a Ruby
252
266
  script or Rakefile.
253
267
  email: