ruby-terraform 0.64.0 → 0.65.0.pre.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +102 -29
  3. data/README.md +29 -9
  4. data/Rakefile +60 -42
  5. data/bin/console +3 -3
  6. data/lib/ruby-terraform.rb +1 -1
  7. data/lib/ruby_terraform.rb +20 -55
  8. data/lib/ruby_terraform/command_line/builder.rb +55 -0
  9. data/lib/ruby_terraform/command_line/option/base.rb +24 -0
  10. data/lib/ruby_terraform/command_line/option/boolean.rb +16 -0
  11. data/lib/ruby_terraform/command_line/option/boolean_value.rb +29 -0
  12. data/lib/ruby_terraform/command_line/option/flag.rb +16 -0
  13. data/lib/ruby_terraform/command_line/option/standard.rb +40 -0
  14. data/lib/ruby_terraform/command_line/option/switch.rb +43 -0
  15. data/lib/ruby_terraform/command_line/options_factory.rb +79 -0
  16. data/lib/ruby_terraform/commands/apply.rb +18 -40
  17. data/lib/ruby_terraform/commands/base.rb +56 -20
  18. data/lib/ruby_terraform/commands/clean.rb +2 -2
  19. data/lib/ruby_terraform/commands/destroy.rb +17 -38
  20. data/lib/ruby_terraform/commands/format.rb +8 -20
  21. data/lib/ruby_terraform/commands/get.rb +11 -10
  22. data/lib/ruby_terraform/commands/import.rb +17 -36
  23. data/lib/ruby_terraform/commands/init.rb +12 -28
  24. data/lib/ruby_terraform/commands/output.rb +13 -21
  25. data/lib/ruby_terraform/commands/plan.rb +13 -36
  26. data/lib/ruby_terraform/commands/refresh.rb +13 -32
  27. data/lib/ruby_terraform/commands/remote_config.rb +9 -17
  28. data/lib/ruby_terraform/commands/show.rb +9 -16
  29. data/lib/ruby_terraform/commands/validate.rb +13 -29
  30. data/lib/ruby_terraform/commands/workspace.rb +14 -14
  31. data/lib/ruby_terraform/errors/execution_error.rb +1 -1
  32. data/lib/ruby_terraform/output.rb +15 -12
  33. data/lib/ruby_terraform/version.rb +1 -1
  34. metadata +105 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8806213ce8d0c4154ef2effa60eaf12160769f5586fe1284a4e8af05af51a8a3
4
- data.tar.gz: 80127429f36f6883b547eb9f91f362e783d098316503116bf85438e8119a9e44
3
+ metadata.gz: fc71a524e8870cabf47b5d3d88f474119bb38ed849afc036af51f95475335c37
4
+ data.tar.gz: 11bf8ae65abe06ff4e0cec9f347a82f613976cbd7378c62fc22fb97d336e05f4
5
5
  SHA512:
6
- metadata.gz: 8202f4ee0d69ca52bb32a95e5de1b958d60c6575785996b43b373e2cf333ec23ee6eaf532cc81b80dbdba5458d3c1fea2acf40f05e4f1e62dacad08938575726
7
- data.tar.gz: f7465522c5b5e3b3b42832b6fff6c529b7c700f1d564668cb789b34290818027f74d61aa514c1972b100864fb8a53ac5453727a51d19b54a2c86047216c2548d
6
+ metadata.gz: a6cd2f1ac3bc0b91d270925ddea294c6c30fe3385061437467fc78c1964bea141ac410212f0358a091e483898bf2d06a4b27931783c444e5176bb184b5ede8c9
7
+ data.tar.gz: 8a863584cdf4d4bc90ebe62cb289b893fd6082f704f828ab00ba21b67228841ceb774b7d16a03332feebcdd4174364a340124b2796ca6e5acc2b2383050a2b83
data/Gemfile.lock CHANGED
@@ -1,52 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.64.0)
4
+ ruby-terraform (0.65.0.pre.5)
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