ruby-terraform 0.63.0.pre.1 → 0.65.0.pre.4

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: fcc491e73d1d8325f28d3ecbed6b38e657c09d312959c1927142616d66ac5ba2
4
- data.tar.gz: 6736c1f2b5a2791968dedd308e58205b30bbc2d0edd2c7ea9c2213b3d2f2666e
3
+ metadata.gz: 89f188a94d3b8b59c9a65a87d151a239bc96c3b3c7612718991d84ee482eede4
4
+ data.tar.gz: dfdb9d0fac5a258cd823a441c8b70fbf05715129c6d4bd32ddeb128d5447f1e8
5
5
  SHA512:
6
- metadata.gz: 4792c8ec47e1d02c240427920cace2887518f26768950d2ffe061480935af153eb0d1fd6fbe9d5ef4bf14f2bdd7aedef6d9202cb07aa9574ea8c3396fcf1aad6
7
- data.tar.gz: f58d0fb1f6210fa843ecd395cd8c3e4c6ba24c9d75ea6fe3ca79e14517444d1bdff8fb5a7f95ec944c2c6f6956447a26c15e1c8eba281687c3e29a0cdd31095a
6
+ metadata.gz: d0bd171c22777b63821ba3bab4d2a4d600e2fd3352c92c8c31e7758dd8732a7d89c060459012f4d63361373cce9e1d0ff0ab7092c6d2710fa52287790289c262
7
+ data.tar.gz: bfbd26e7b628847187de85f8ef2753d2f84ebeaaad739f1c9b129a4db1f201bc09fb7c854d8b338a48df0d7288188a3ea510bb124abe5366cbb311671d538b9a
data/Gemfile.lock CHANGED
@@ -1,52 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.63.0.pre.1)
4
+ ruby-terraform (0.65.0.pre.4)
5
5
  lino (>= 1.5)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.3.4)
10
+ activesupport (6.1.3.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (>= 0.7, < 2)
13
- minitest (~> 5.1)
14
- tzinfo (~> 1.1)
15
- zeitwerk (~> 2.2, >= 2.2.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ zeitwerk (~> 2.3)
16
16
  addressable (2.7.0)
17
17
  public_suffix (>= 2.0.2, < 5.0)
18
+ ast (2.4.2)
19
+ coderay (1.1.3)
18
20
  colored2 (3.1.2)
19
- concurrent-ruby (1.1.7)
21
+ concurrent-ruby (1.1.8)
20
22
  diff-lcs (1.4.4)
21
- excon (0.78.1)
22
- faraday (1.1.0)
23
+ docile (1.3.5)
24
+ excon (0.79.0)
25
+ faker (2.17.0)
26
+ i18n (>= 1.6, < 2)
27
+ faraday (1.3.0)
28
+ faraday-net_http (~> 1.0)
23
29
  multipart-post (>= 1.2, < 3)
24
30
  ruby2_keywords
25
- gem-release (2.2.0)
31
+ faraday-net_http (1.0.1)
32
+ ffi (1.15.0)
33
+ formatador (0.2.5)
34
+ gem-release (2.2.1)
35
+ guard (2.16.2)
36
+ formatador (>= 0.2.4)
37
+ listen (>= 2.7, < 4.0)
38
+ lumberjack (>= 1.0.12, < 2.0)
39
+ nenv (~> 0.1)
40
+ notiffany (~> 0.0)
41
+ pry (>= 0.9.12)
42
+ shellany (~> 0.0)
43
+ thor (>= 0.18.1)
44
+ guard-compat (1.2.1)
45
+ guard-rspec (4.7.3)
46
+ guard (~> 2.1)
47
+ guard-compat (~> 1.1)
48
+ rspec (>= 2.99.0, < 4.0)
26
49
  hamster (3.0.0)
27
50
  concurrent-ruby (~> 1.0)
28
- i18n (1.8.5)
51
+ i18n (1.8.10)
29
52
  concurrent-ruby (~> 1.0)
30
- lino (1.5.0)
53
+ lino (1.9.0)
31
54
  hamster (~> 3.0)
32
55
  open4 (~> 1.3)
33
- minitest (5.14.2)
56
+ listen (3.5.1)
57
+ rb-fsevent (~> 0.10, >= 0.10.3)
58
+ rb-inotify (~> 0.9, >= 0.9.10)
59
+ lumberjack (1.2.8)
60
+ method_source (1.0.0)
61
+ minitest (5.14.4)
34
62
  multipart-post (2.1.1)
35
- octokit (4.19.0)
63
+ nenv (0.3.0)
64
+ notiffany (0.1.3)
65
+ nenv (~> 0.1)
66
+ shellany (~> 0.0)
67
+ octokit (4.20.0)
36
68
  faraday (>= 0.9)
37
69
  sawyer (~> 0.8.0, >= 0.5.3)
38
70
  open4 (1.3.4)
71
+ parallel (1.20.1)
72
+ parser (3.0.0.0)
73
+ ast (~> 2.4.1)
74
+ pry (0.14.0)
75
+ coderay (~> 1.1)
76
+ method_source (~> 1.0)
39
77
  public_suffix (4.0.6)
40
- rake (13.0.1)
78
+ rainbow (3.0.0)
79
+ rake (13.0.3)
41
80
  rake_circle_ci (0.9.0)
42
81
  colored2 (~> 3.1)
43
82
  excon (~> 0.72)
44
83
  rake_factory (~> 0.23)
45
84
  sshkey (~> 2.0)
46
- rake_factory (0.27.0)
85
+ rake_factory (0.29.0)
47
86
  activesupport (>= 4)
48
87
  rake (~> 13.0)
49
- rake_github (0.5.0)
88
+ rake_github (0.7.0)
50
89
  colored2 (~> 3.1)
51
90
  octokit (~> 4.16)
52
91
  rake_factory (~> 0.23)
@@ -54,48 +93,82 @@ GEM
54
93
  rake_gpg (0.14.0)
55
94
  rake_factory (>= 0.23, < 1)
56
95
  ruby_gpg2 (>= 0.6, < 1)
57
- rake_ssh (0.4.0)
96
+ rake_ssh (0.6.0)
58
97
  colored2 (~> 3.1)
59
98
  rake_factory (~> 0.23)
60
99
  sshkey (~> 2.0)
100
+ rb-fsevent (0.10.4)
101
+ rb-inotify (0.10.1)
102
+ ffi (~> 1.0)
103
+ regexp_parser (2.1.1)
104
+ rexml (3.2.4)
61
105
  rspec (3.10.0)
62
106
  rspec-core (~> 3.10.0)
63
107
  rspec-expectations (~> 3.10.0)
64
108
  rspec-mocks (~> 3.10.0)
65
- rspec-core (3.10.0)
109
+ rspec-core (3.10.1)
66
110
  rspec-support (~> 3.10.0)
67
- rspec-expectations (3.10.0)
111
+ rspec-expectations (3.10.1)
68
112
  diff-lcs (>= 1.2.0, < 2.0)
69
113
  rspec-support (~> 3.10.0)
70
- rspec-mocks (3.10.0)
114
+ rspec-mocks (3.10.2)
71
115
  diff-lcs (>= 1.2.0, < 2.0)
72
116
  rspec-support (~> 3.10.0)
73
- rspec-support (3.10.0)
74
- ruby2_keywords (0.0.2)
75
- ruby_gpg2 (0.6.0)
117
+ rspec-support (3.10.2)
118
+ rubocop (1.12.0)
119
+ parallel (~> 1.10)
120
+ parser (>= 3.0.0.0)
121
+ rainbow (>= 2.2.2, < 4.0)
122
+ regexp_parser (>= 1.8, < 3.0)
123
+ rexml
124
+ rubocop-ast (>= 1.2.0, < 2.0)
125
+ ruby-progressbar (~> 1.7)
126
+ unicode-display_width (>= 1.4.0, < 3.0)
127
+ rubocop-ast (1.4.1)
128
+ parser (>= 2.7.1.5)
129
+ rubocop-rspec (2.2.0)
130
+ rubocop (~> 1.0)
131
+ rubocop-ast (>= 1.1.0)
132
+ ruby-progressbar (1.11.0)
133
+ ruby2_keywords (0.0.4)
134
+ ruby_gpg2 (0.8.0)
76
135
  lino (>= 1.5)
77
136
  sawyer (0.8.2)
78
137
  addressable (>= 2.3.5)
79
138
  faraday (> 0.8, < 2.0)
139
+ shellany (0.0.1)
140
+ simplecov (0.21.2)
141
+ docile (~> 1.1)
142
+ simplecov-html (~> 0.11)
143
+ simplecov_json_formatter (~> 0.1)
144
+ simplecov-html (0.12.3)
145
+ simplecov_json_formatter (0.1.2)
80
146
  sshkey (2.0.0)
81
- thread_safe (0.3.6)
82
- tzinfo (1.2.8)
83
- thread_safe (~> 0.1)
84
- zeitwerk (2.4.1)
147
+ thor (1.1.0)
148
+ tzinfo (2.0.4)
149
+ concurrent-ruby (~> 1.0)
150
+ unicode-display_width (2.0.0)
151
+ zeitwerk (2.4.2)
85
152
 
86
153
  PLATFORMS
87
154
  ruby
88
155
 
89
156
  DEPENDENCIES
90
157
  bundler (~> 2.0)
158
+ faker (~> 2.17)
91
159
  gem-release (~> 2.1)
160
+ guard (~> 2.16)
161
+ guard-rspec (~> 4.7)
92
162
  rake (~> 13.0)
93
163
  rake_circle_ci (~> 0.9)
94
164
  rake_github (~> 0.5)
95
165
  rake_gpg (~> 0.12)
96
166
  rake_ssh (~> 0.4)
97
167
  rspec (~> 3.9)
168
+ rubocop (~> 1.12)
169
+ rubocop-rspec (~> 2.2)
98
170
  ruby-terraform!
171
+ simplecov (~> 0.21)
99
172
 
100
173
  BUNDLED WITH
101
- 2.2.4
174
+ 2.2.15
data/README.md CHANGED
@@ -467,7 +467,7 @@ RubyTerraform.workspace(operation: 'delete', workspace: 'staging')
467
467
  arguments:
468
468
  * `directory`: the directory containing terraform configuration, the default is
469
469
  the current path.
470
- * `operation`: `list`, `select`, `new` or `delete`. default `list`.
470
+ * `operation`: `list`, `select`, `new` or `delete`. default `list`.
471
471
  * `workspace`: Workspace name.
472
472
 
473
473
 
@@ -551,15 +551,35 @@ interactive input from the terminal.
551
551
 
552
552
  ## Development
553
553
 
554
- After checking out the repo, run `bin/setup` to install dependencies. Then,
555
- run `rake spec` to run the tests. You can also run `bin/console` for an
556
- interactive prompt that will allow you to experiment.
554
+ To install dependencies and run the build, run the pre-commit build:
557
555
 
558
- To install this gem onto your local machine, run `bundle exec rake install`. To
559
- release a new version, update the version number in `version.rb`, and then run
560
- `bundle exec rake release`, which will create a git tag for the version, push
561
- git commits and tags, and push the `.gem` file to
562
- [rubygems.org](https://rubygems.org).
556
+ ```shell script
557
+ ./go
558
+ ```
559
+
560
+ This runs all unit tests and other checks including coverage and code linting /
561
+ formatting.
562
+
563
+ To run only the unit tests, including coverage:
564
+
565
+ ```shell script
566
+ ./go test:unit
567
+ ```
568
+
569
+ To attempt to fix any code linting / formatting issues:
570
+
571
+ ```shell script
572
+ ./go library:fix
573
+ ```
574
+
575
+ To check for code linting / formatting issues without fixing:
576
+
577
+ ```shell script
578
+ ./go library:check
579
+ ```
580
+
581
+ You can also run `bin/console` for an interactive prompt that will allow you to
582
+ experiment.
563
583
 
564
584
  ### Managing CircleCI keys
565
585
 
data/Rakefile CHANGED
@@ -5,10 +5,12 @@ require 'rake_ssh'
5
5
  require 'rake_gpg'
6
6
  require 'securerandom'
7
7
  require 'rspec/core/rake_task'
8
+ require 'rubocop/rake_task'
8
9
 
9
- task :default => :spec
10
-
11
- RSpec::Core::RakeTask.new(:spec)
10
+ task default: [
11
+ #:'library:fix',
12
+ :'test:unit'
13
+ ]
12
14
 
13
15
  namespace :encryption do
14
16
  namespace :passphrase do
@@ -23,83 +25,99 @@ end
23
25
  namespace :keys do
24
26
  namespace :deploy do
25
27
  RakeSSH.define_key_tasks(
26
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
28
+ path: 'config/secrets/ci/',
29
+ comment: 'maintainers@infrablocks.io'
30
+ )
28
31
  end
29
32
 
30
33
  namespace :gpg do
31
34
  RakeGPG.define_generate_key_task(
32
- output_directory: 'config/secrets/ci',
33
- name_prefix: 'gpg',
34
- owner_name: 'InfraBlocks Maintainers',
35
- owner_email: 'maintainers@infrablocks.io',
36
- owner_comment: 'ruby_terraform CI Key')
35
+ output_directory: 'config/secrets/ci',
36
+ name_prefix: 'gpg',
37
+ owner_name: 'InfraBlocks Maintainers',
38
+ owner_email: 'maintainers@infrablocks.io',
39
+ owner_comment: 'ruby_terraform CI Key'
40
+ )
37
41
  end
38
42
  end
39
43
 
44
+ RuboCop::RakeTask.new
45
+
46
+ namespace :library do
47
+ desc 'Run all checks of the library'
48
+ task check: [:rubocop]
49
+
50
+ desc 'Attempt to automatically fix issues with the library'
51
+ task fix: [:'rubocop:auto_correct']
52
+ end
53
+
54
+ namespace :test do
55
+ RSpec::Core::RakeTask.new(:unit)
56
+ end
57
+
40
58
  RakeCircleCI.define_project_tasks(
41
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/ruby_terraform'
59
+ namespace: :circle_ci,
60
+ project_slug: 'github/infrablocks/ruby_terraform'
43
61
  ) do |t|
44
62
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
63
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
64
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
65
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
66
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
67
+ ENCRYPTION_PASSPHRASE:
68
+ File.read('config/secrets/ci/encryption.passphrase')
69
+ .chomp
52
70
  }
53
71
  t.checkout_keys = []
54
72
  t.ssh_keys = [
55
- {
56
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
58
- }
73
+ {
74
+ hostname: 'github.com',
75
+ private_key: File.read('config/secrets/ci/ssh.private')
76
+ }
59
77
  ]
60
78
  end
61
79
 
62
80
  RakeGithub.define_repository_tasks(
63
- namespace: :github,
64
- repository: 'infrablocks/ruby_terraform',
81
+ namespace: :github,
82
+ repository: 'infrablocks/ruby_terraform'
65
83
  ) do |t|
66
84
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
85
+ YAML.load_file('config/secrets/github/config.yaml')
68
86
 
69
- t.access_token = github_config["github_personal_access_token"]
87
+ t.access_token = github_config['github_personal_access_token']
70
88
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
74
- }
89
+ {
90
+ title: 'CircleCI',
91
+ public_key: File.read('config/secrets/ci/ssh.public')
92
+ }
75
93
  ]
76
94
  end
77
95
 
78
96
  namespace :pipeline do
79
- task :prepare => [
80
- :'circle_ci:project:follow',
81
- :'circle_ci:env_vars:ensure',
82
- :'circle_ci:checkout_keys:ensure',
83
- :'circle_ci:ssh_keys:ensure',
84
- :'github:deploy_keys:ensure'
97
+ task prepare: %i[
98
+ circle_ci:project:follow
99
+ circle_ci:env_vars:ensure
100
+ circle_ci:checkout_keys:ensure
101
+ circle_ci:ssh_keys:ensure
102
+ github:deploy_keys:ensure
85
103
  ]
86
104
  end
87
105
 
88
106
  namespace :version do
89
- desc "Bump version for specified type (pre, major, minor, patch)"
107
+ desc 'Bump version for specified type (pre, major, minor, patch)'
90
108
  task :bump, [:type] do |_, args|
91
109
  bump_version_for(args.type)
92
110
  end
93
111
  end
94
112
 
95
- desc "Release gem"
113
+ desc 'Release gem'
96
114
  task :release do
97
- sh "gem release --tag --push"
115
+ sh 'gem release --tag --push'
98
116
  end
99
117
 
100
118
  def bump_version_for(version_type)
101
- sh "gem bump --version #{version_type} " +
102
- "&& bundle install " +
103
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
104
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
119
+ sh "gem bump --version #{version_type} " \
120
+ '&& bundle install ' \
121
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
122
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
105
123
  end
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "ruby_terraform"
3
+ require 'bundler/setup'
4
+ require 'ruby_terraform'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "ruby_terraform"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,3 +1,3 @@
1
1
  # Enable `require 'ruby-terraform'`, to match the gem name
2
2
 
3
- require_relative 'ruby_terraform.rb'
3
+ require_relative 'ruby_terraform'
@@ -21,60 +21,25 @@ module RubyTerraform
21
21
  end
22
22
 
23
23
  module ClassMethods
24
- def clean(opts = {})
25
- Commands::Clean.new.execute(opts)
26
- end
27
-
28
- def init(opts = {})
29
- Commands::Init.new.execute(opts)
30
- end
31
-
32
- def get(opts = {})
33
- Commands::Get.new.execute(opts)
34
- end
35
-
36
- def validate(opts = {})
37
- Commands::Validate.new.execute(opts)
38
- end
39
-
40
- def plan(opts = {})
41
- Commands::Plan.new.execute(opts)
42
- end
43
-
44
- def apply(opts = {})
45
- Commands::Apply.new.execute(opts)
46
- end
47
-
48
- def destroy(opts = {})
49
- Commands::Destroy.new.execute(opts)
50
- end
51
-
52
- def remote_config(opts = {})
53
- Commands::RemoteConfig.new.execute(opts)
54
- end
55
-
56
- def refresh(opts = {})
57
- Commands::Refresh.new.execute(opts)
58
- end
59
-
60
- def output(opts = {})
61
- Commands::Output.new.execute(opts)
62
- end
63
-
64
- def show(opts = {})
65
- Commands::Show.new.execute(opts)
66
- end
67
-
68
- def workspace(opts = {})
69
- Commands::Workspace.new.execute(opts)
70
- end
71
-
72
- def import(opts = {})
73
- Commands::Import.new.execute(opts)
74
- end
75
-
76
- def format(opts = {})
77
- Commands::Format.new.execute(opts)
24
+ {
25
+ apply: RubyTerraform::Commands::Apply,
26
+ clean: RubyTerraform::Commands::Clean,
27
+ destroy: RubyTerraform::Commands::Destroy,
28
+ format: RubyTerraform::Commands::Format,
29
+ get: RubyTerraform::Commands::Get,
30
+ import: RubyTerraform::Commands::Import,
31
+ init: RubyTerraform::Commands::Init,
32
+ output: RubyTerraform::Commands::Output,
33
+ plan: RubyTerraform::Commands::Plan,
34
+ refresh: RubyTerraform::Commands::Refresh,
35
+ remote_config: RubyTerraform::Commands::RemoteConfig,
36
+ show: RubyTerraform::Commands::Show,
37
+ validate: RubyTerraform::Commands::Validate,
38
+ workspace: RubyTerraform::Commands::Workspace
39
+ }.each do |method, command_class|
40
+ define_method(method) do |opts = {}|
41
+ command_class.new.execute(opts)
42
+ end
78
43
  end
79
44
  end
80
45
  extend ClassMethods
@@ -107,7 +72,7 @@ module RubyTerraform
107
72
  end
108
73
 
109
74
  def write(*args)
110
- @targets.each {|t| t.write(*args)}
75
+ @targets.each { |t| t.write(*args) }
111
76
  end
112
77
 
113
78
  def close
@@ -1,5 +1,4 @@
1
1
  require 'json'
2
- require 'lino'
3
2
  require_relative 'base'
4
3
 
5
4
  module RubyTerraform
@@ -21,29 +20,30 @@ module RubyTerraform
21
20
  no_color = opts[:no_color]
22
21
 
23
22
  builder
24
- .with_subcommand('apply') do |sub|
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
- end
30
- sub = sub.with_option('-var-file', var_file) if var_file
31
- var_files.each do |file|
32
- sub = sub.with_option('-var-file', file)
33
- end
34
- sub = sub.with_option('-target', target) if target
35
- targets.each do |file|
36
- sub = sub.with_option('-target', file)
37
- end
38
- sub = sub.with_option('-state', state) if state
39
- sub = sub.with_option('-input', input) if input
40
- sub = sub.with_option('-auto-approve', auto_approve) unless
41
- auto_approve.nil?
42
- sub = sub.with_option('-backup', backup) if backup
43
- sub = sub.with_flag('-no-color') if no_color
44
- sub
45
- end
46
- .with_argument(plan || directory)
23
+ .with_subcommand('apply') do |sub|
24
+ vars.each do |key, value|
25
+ var_value = value.is_a?(String) ? value : JSON.generate(value)
26
+ sub = sub.with_option(
27
+ '-var', "'#{key}=#{var_value}'", separator: ' '
28
+ )
29
+ end
30
+ sub = sub.with_option('-var-file', var_file) if var_file
31
+ var_files.each do |file|
32
+ sub = sub.with_option('-var-file', file)
33
+ end
34
+ sub = sub.with_option('-target', target) if target
35
+ targets.each do |file|
36
+ sub = sub.with_option('-target', file)
37
+ end
38
+ sub = sub.with_option('-state', state) if state
39
+ sub = sub.with_option('-input', input) if input
40
+ sub = sub.with_option('-auto-approve', auto_approve) unless
41
+ auto_approve.nil?
42
+ sub = sub.with_option('-backup', backup) if backup
43
+ sub = sub.with_flag('-no-color') if no_color
44
+ sub
45
+ end
46
+ .with_argument(plan || directory)
47
47
  end
48
48
  end
49
49
  end
@@ -5,7 +5,8 @@ module RubyTerraform
5
5
  module Commands
6
6
  class Base
7
7
  def initialize(
8
- binary: nil, logger: nil, stdin: nil, stdout: nil, stderr: nil)
8
+ binary: nil, logger: nil, stdin: nil, stdout: nil, stderr: nil
9
+ )
9
10
  @binary = binary || RubyTerraform.configuration.binary
10
11
  @logger = logger || RubyTerraform.configuration.logger
11
12
  @stdin = stdin || RubyTerraform.configuration.stdin
@@ -18,12 +19,12 @@ module RubyTerraform
18
19
 
19
20
  do_before(opts)
20
21
  command = configure_command(builder, opts).build
21
- logger.debug("Running '#{command.to_s}'.")
22
+ logger.debug("Running '#{command}'.")
22
23
 
23
24
  command.execute(
24
- stdin: stdin,
25
- stdout: stdout,
26
- stderr: stderr
25
+ stdin: stdin,
26
+ stdout: stdout,
27
+ stderr: stderr
27
28
  )
28
29
  do_after(opts)
29
30
  rescue Open4::SpawnError
@@ -37,23 +38,20 @@ module RubyTerraform
37
38
  attr_reader :binary, :logger, :stdin, :stdout, :stderr
38
39
 
39
40
  def command_name
40
- self.class.to_s.split("::")[-1].downcase
41
+ self.class.to_s.split('::')[-1].downcase
41
42
  end
42
43
 
43
44
  def instantiate_builder
44
45
  Lino::CommandLineBuilder
45
- .for_command(binary)
46
- .with_option_separator('=')
46
+ .for_command(binary)
47
+ .with_option_separator('=')
47
48
  end
48
49
 
49
- def do_before(opts)
50
- end
50
+ def do_before(opts); end
51
51
 
52
- def configure_command(builder, opts)
53
- end
52
+ def configure_command(builder, opts); end
54
53
 
55
- def do_after(opts)
56
- end
54
+ def do_after(opts); end
57
55
  end
58
56
  end
59
57
  end
@@ -6,7 +6,7 @@ module RubyTerraform
6
6
  attr_reader :logger
7
7
 
8
8
  def initialize(directory: nil, logger: nil)
9
- @directory = directory ? directory : '.terraform'
9
+ @directory = directory || '.terraform'
10
10
  @logger = logger || RubyTerraform.configuration.logger
11
11
  end
12
12
 
@@ -14,7 +14,7 @@ module RubyTerraform
14
14
  directory = opts[:directory] || @directory
15
15
  begin
16
16
  logger.info "Cleaning terraform directory '#{directory}'."
17
- FileUtils.rm_r(directory, :secure => true)
17
+ FileUtils.rm_r(directory, secure: true)
18
18
  rescue Errno::ENOENT => e
19
19
  logger.error "Couldn't clean '#{directory}': #{e.message}"
20
20
  end
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -19,29 +18,30 @@ module RubyTerraform
19
18
  auto_approve = opts[:auto_approve]
20
19
 
21
20
  builder
22
- .with_subcommand('destroy') do |sub|
23
- vars.each do |key, value|
24
- var_value = value.is_a?(String) ? value : JSON.generate(value)
25
- sub = sub.with_option(
26
- '-var', "'#{key}=#{var_value}'", separator: ' ')
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 |target_name|
34
- sub = sub.with_option('-target', target_name)
35
- end
36
- sub = sub.with_option('-state', state) if state
37
- sub = sub.with_option('-auto-approve', auto_approve) unless
38
- auto_approve.nil?
39
- sub = sub.with_option('-backup', backup) if backup
40
- sub = sub.with_flag('-no-color') if no_color
41
- sub = sub.with_flag('-force') if force
42
- sub
43
- end
44
- .with_argument(directory)
21
+ .with_subcommand('destroy') 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 |target_name|
34
+ sub = sub.with_option('-target', target_name)
35
+ end
36
+ sub = sub.with_option('-state', state) if state
37
+ sub = sub.with_option('-auto-approve', auto_approve) unless
38
+ auto_approve.nil?
39
+ sub = sub.with_option('-backup', backup) if backup
40
+ sub = sub.with_flag('-no-color') if no_color
41
+ sub = sub.with_flag('-force') if force
42
+ sub
43
+ end
44
+ .with_argument(directory)
45
45
  end
46
46
  end
47
47
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lino'
4
3
  require_relative 'base'
5
4
 
6
5
  module RubyTerraform
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -6,13 +5,13 @@ module RubyTerraform
6
5
  class Get < Base
7
6
  def configure_command(builder, opts)
8
7
  builder
9
- .with_subcommand('get') do |sub|
10
- sub = sub.with_option('-update', true) if opts[:update]
11
- sub = sub.with_flag('-no-color') if opts[:no_color]
12
- sub
13
- end
14
- .with_argument(opts[:directory])
8
+ .with_subcommand('get') do |sub|
9
+ sub = sub.with_option('-update', true) if opts[:update]
10
+ sub = sub.with_flag('-no-color') if opts[:no_color]
11
+ sub
12
+ end
13
+ .with_argument(opts[:directory])
15
14
  end
16
15
  end
17
16
  end
18
- end
17
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lino'
3
+ require 'json'
4
4
  require_relative 'base'
5
5
 
6
6
  module RubyTerraform
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -15,21 +14,28 @@ module RubyTerraform
15
14
  force_copy = opts[:force_copy]
16
15
 
17
16
  builder = builder
18
- .with_subcommand('init') do |sub|
19
- sub = sub.with_option('-backend', backend) unless backend.nil?
20
- sub = sub.with_option('-force-copy', force_copy) unless force_copy.nil?
21
- sub = sub.with_option('-get', get) unless get.nil?
22
- sub = sub.with_option('-from-module', source) if source
23
- sub = sub.with_flag('-no-color') if no_color
24
- sub = sub.with_option('-plugin-dir', plugin_dir) unless plugin_dir.nil?
25
- backend_config.each do |key, value|
26
- sub = sub.with_option(
27
- '-backend-config',
28
- "'#{key}=#{value}'",
29
- separator: ' ')
30
- end
31
- sub
32
- end
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
33
39
 
34
40
  builder = builder.with_argument(path) if path
35
41
 
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require 'stringio'
3
2
  require_relative 'base'
4
3
 
@@ -19,7 +18,7 @@ module RubyTerraform
19
18
  mod = opts[:module]
20
19
 
21
20
  builder = builder
22
- .with_subcommand('output') do |sub|
21
+ .with_subcommand('output') do |sub|
23
22
  sub = sub.with_flag('-no-color') if no_color
24
23
  sub = sub.with_flag('-json') if json
25
24
  sub = sub.with_option('-state', state) if state
@@ -1,4 +1,4 @@
1
- require 'lino'
1
+ require 'json'
2
2
  require_relative 'base'
3
3
 
4
4
  module RubyTerraform
@@ -18,28 +18,29 @@ module RubyTerraform
18
18
  no_color = opts[:no_color]
19
19
 
20
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
- end
27
- sub = sub.with_option('-var-file', var_file) if var_file
28
- var_files.each do |file|
29
- sub = sub.with_option('-var-file', file)
30
- end
31
- sub = sub.with_option('-target', target) if target
32
- targets.each do |file|
33
- sub = sub.with_option('-target', file)
34
- end
35
- sub = sub.with_option('-state', state) if state
36
- sub = sub.with_option('-out', plan) if plan
37
- sub = sub.with_option('-input', input) if input
38
- sub = sub.with_flag('-destroy') if destroy
39
- sub = sub.with_flag('-no-color') if no_color
40
- sub
41
- end
42
- .with_argument(directory)
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)
43
44
  end
44
45
  end
45
46
  end
@@ -1,4 +1,4 @@
1
- require 'lino'
1
+ require 'json'
2
2
  require_relative 'base'
3
3
 
4
4
  module RubyTerraform
@@ -16,26 +16,27 @@ module RubyTerraform
16
16
  no_color = opts[:no_color]
17
17
 
18
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
- 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('-input', input) if input
31
- sub = sub.with_option('-target', target) if target
32
- targets.each do |target_name|
33
- sub = sub.with_option('-target', target_name)
34
- end
35
- sub = sub.with_flag('-no-color') if no_color
36
- sub
37
- end
38
- .with_argument(directory)
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)
39
40
  end
40
41
  end
41
42
  end
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -10,18 +9,19 @@ module RubyTerraform
10
9
  backend_config = opts[:backend_config] || {}
11
10
 
12
11
  builder
13
- .with_subcommand('remote')
14
- .with_subcommand('config') do |sub|
15
- sub = sub.with_option('-backend', backend) if backend
16
- backend_config.each do |key, value|
17
- sub = sub.with_option(
18
- '-backend-config', "'#{key}=#{value}'", separator: ' ')
19
- end
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
20
20
 
21
- sub = sub.with_flag('-no-color') if no_color
22
- sub
23
- end
21
+ sub = sub.with_flag('-no-color') if no_color
22
+ sub
23
+ end
24
24
  end
25
25
  end
26
26
  end
27
- end
27
+ end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lino'
4
3
  require_relative 'base'
5
4
 
6
5
  module RubyTerraform
@@ -1,4 +1,4 @@
1
- require 'lino'
1
+ require 'json'
2
2
  require_relative 'base'
3
3
 
4
4
  module RubyTerraform
@@ -15,24 +15,25 @@ module RubyTerraform
15
15
  json_format = opts[:json]
16
16
 
17
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
- end
24
- sub = sub.with_option('-var-file', var_file) if var_file
25
- var_files.each do |file|
26
- sub = sub.with_option('-var-file', file)
27
- end
28
- sub = sub.with_option('-state', state) if state
29
- sub = sub.with_option('-check-variables', check_variables) unless
30
- check_variables.nil?
31
- sub = sub.with_flag('-no-color') if no_color
32
- sub = sub.with_flag('-json') if json_format
33
- sub
34
- end
35
- .with_argument(directory)
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)
36
37
  end
37
38
  end
38
39
  end
@@ -1,4 +1,3 @@
1
- require 'lino'
2
1
  require_relative 'base'
3
2
 
4
3
  module RubyTerraform
@@ -10,15 +9,13 @@ module RubyTerraform
10
9
  workspace = opts[:workspace] || nil
11
10
 
12
11
  builder = builder
13
- .with_subcommand('workspace')
14
- .with_subcommand(operation)
12
+ .with_subcommand('workspace')
13
+ .with_subcommand(operation)
15
14
 
16
15
  builder = builder.with_subcommand(workspace) if
17
16
  workspace && operation != 'list'
18
- builder = builder.with_argument(directory)
19
-
20
- builder
17
+ builder.with_argument(directory)
21
18
  end
22
19
  end
23
20
  end
24
- end
21
+ end
@@ -3,4 +3,4 @@ module RubyTerraform
3
3
  class ExecutionError < StandardError
4
4
  end
5
5
  end
6
- end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyTerraform
2
- VERSION = "0.63.0.pre.1"
2
+ VERSION = '0.65.0.pre.4'.freeze
3
3
  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.63.0.pre.1
4
+ version: 0.65.0.pre.4
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-01-02 00:00:00.000000000 Z
11
+ date: 2021-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lino
@@ -38,6 +38,62 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faker
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gem-release
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.7'
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: rake
43
99
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +137,33 @@ dependencies:
81
137
  - !ruby/object:Gem::Version
82
138
  version: '0.5'
83
139
  - !ruby/object:Gem::Dependency
84
- name: rake_ssh
140
+ name: rake_gpg
85
141
  requirement: !ruby/object:Gem::Requirement
86
142
  requirements:
87
143
  - - "~>"
88
144
  - !ruby/object:Gem::Version
89
- version: '0.4'
145
+ version: '0.12'
90
146
  type: :development
91
147
  prerelease: false
92
148
  version_requirements: !ruby/object:Gem::Requirement
93
149
  requirements:
94
150
  - - "~>"
95
151
  - !ruby/object:Gem::Version
96
- version: '0.4'
152
+ version: '0.12'
97
153
  - !ruby/object:Gem::Dependency
98
- name: rake_gpg
154
+ name: rake_ssh
99
155
  requirement: !ruby/object:Gem::Requirement
100
156
  requirements:
101
157
  - - "~>"
102
158
  - !ruby/object:Gem::Version
103
- version: '0.12'
159
+ version: '0.4'
104
160
  type: :development
105
161
  prerelease: false
106
162
  version_requirements: !ruby/object:Gem::Requirement
107
163
  requirements:
108
164
  - - "~>"
109
165
  - !ruby/object:Gem::Version
110
- version: '0.12'
166
+ version: '0.4'
111
167
  - !ruby/object:Gem::Dependency
112
168
  name: rspec
113
169
  requirement: !ruby/object:Gem::Requirement
@@ -123,19 +179,47 @@ dependencies:
123
179
  - !ruby/object:Gem::Version
124
180
  version: '3.9'
125
181
  - !ruby/object:Gem::Dependency
126
- name: gem-release
182
+ name: rubocop
127
183
  requirement: !ruby/object:Gem::Requirement
128
184
  requirements:
129
185
  - - "~>"
130
186
  - !ruby/object:Gem::Version
131
- version: '2.1'
187
+ version: '1.12'
132
188
  type: :development
133
189
  prerelease: false
134
190
  version_requirements: !ruby/object:Gem::Requirement
135
191
  requirements:
136
192
  - - "~>"
137
193
  - !ruby/object:Gem::Version
138
- version: '2.1'
194
+ version: '1.12'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop-rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '2.2'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '2.2'
209
+ - !ruby/object:Gem::Dependency
210
+ name: simplecov
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0.21'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0.21'
139
223
  description: Wraps the Terraform CLI so that Terraform can be invoked from a Ruby
140
224
  script or Rakefile.
141
225
  email: