tfwrapper 0.5.0 → 0.5.1

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
  SHA1:
3
- metadata.gz: 73a99a40047a490174b186e5bf5c6b58dedea114
4
- data.tar.gz: f64131d4e1a68fae63dc3b86465b64480a3edae3
3
+ metadata.gz: c135173a4a6dbe8d20af3194d7709464d55f1cae
4
+ data.tar.gz: 1e8916123d75be89c7cac726147245412a334fe3
5
5
  SHA512:
6
- metadata.gz: 7e3d6202be5a238dc9a358ed190aa6debbef62e5f56cac5b365935afe407a700e46a3166e24af34640f00a21667dd34adec292bb1c7125fe82129da98eefeeed
7
- data.tar.gz: 1b4b83ca1147ae1955d3e571e087467f792db7107b76c2d9f421ff9fd37dd4512860ca719b32a7fd8b56e8861b1785ff45b439eea01faa454e4169b0dd1b040c
6
+ metadata.gz: 3e2429724f5641075d767180b3bb62f738188604a94d8bd435279c979773469c07fcb78672d8c291a570efdab38610d7492db9074aeab0c4e4d80c3573f8ecae
7
+ data.tar.gz: 69fbef7e6e4daf1ff99136bc9aad1963edb3f5ad86d3adcff88b589b4094c17874e9bf324b5a3b83cd2b0afff2407a178bc9c7b7ea20f3aff1d38c79f9b07be6
@@ -1,3 +1,7 @@
1
+ Version 0.5.1
2
+
3
+ - Fix bug where terraform plan errors were suppressed if a plan run with landscape support enabled exited non-zero.
4
+
1
5
  Version 0.5.0
2
6
 
3
7
  - Add support for using terraform_landscape gem, if present, to reformat plan output; see README for usage.
data/README.md CHANGED
@@ -44,7 +44,7 @@ with 1.9.3 is simply too high to justify.
44
44
  Add to your ``Gemfile``:
45
45
 
46
46
  ```ruby
47
- gem 'tfwrapper', '~> 0.5.0'
47
+ gem 'tfwrapper', '~> 0.5.1'
48
48
  ```
49
49
 
50
50
  ### Supported Terraform Versions
@@ -404,6 +404,8 @@ module TFWrapper
404
404
  end
405
405
  # end exponential backoff
406
406
  unless status.zero?
407
+ # if we weren't streaming output, send it now
408
+ STDERR.puts out_err unless stream_type == :stream
407
409
  raise StandardError, "Errors have occurred executing: '#{cmd}' " \
408
410
  "(exited #{status})"
409
411
  end
@@ -4,5 +4,5 @@ module TFWrapper
4
4
  # version of the Gem/module; used in the gemspec and in messages.
5
5
  # NOTE: When updating this, also update the version in the "Installation"
6
6
  # section of README.md
7
- VERSION = '0.5.0'
7
+ VERSION = '0.5.1'
8
8
  end
@@ -922,6 +922,34 @@ describe 'tfwrapper' do
922
922
  end
923
923
  end
924
924
  end
925
+ context 'when terraform fails' do
926
+ describe 'failing_tf:plan' do
927
+ before(:all) do
928
+ @out_err, @ecode = Open3.capture2e(
929
+ 'timeout -k 60 45 bundle exec rake failing_tf:plan',
930
+ chdir: @fixturepath
931
+ )
932
+ @varpath = File.join(@fixturepath, 'failing_build.tfvars.json')
933
+ end
934
+ after(:all) do
935
+ File.delete(@varpath) if File.file?(@varpath)
936
+ end
937
+ it 'does not time out' do
938
+ expect(@ecode.exitstatus).to_not eq(124)
939
+ expect(@ecode.exitstatus).to_not eq(137)
940
+ end
941
+ it 'exits 1' do
942
+ expect(@ecode.exitstatus).to eq(1)
943
+ end
944
+ it 'returns the terraform output' do
945
+ expected = clean_tf_plan_output(
946
+ File.read(File.join(@fixturepath, 'when_terraform_fails.out')),
947
+ latest_tf_ver, @fixturepath
948
+ )
949
+ expect(@out_err.strip).to eq(expected.strip)
950
+ end
951
+ end
952
+ end
925
953
  end
926
954
  end
927
955
  end
@@ -30,3 +30,9 @@ TFWrapper::RakeTasks.install_tasks(
30
30
  namespace_prefix: 'lines',
31
31
  landscape_progress: :lines
32
32
  )
33
+
34
+ TFWrapper::RakeTasks.install_tasks(
35
+ 'failingTerraform/',
36
+ namespace_prefix: 'failing',
37
+ landscape_progress: :dots
38
+ )
@@ -0,0 +1,28 @@
1
+ terraform {
2
+ required_version = "> 0.9.0"
3
+ backend "consul" {
4
+ address = "127.0.0.1:8500"
5
+ path = "terraform/landscapeTestFailure"
6
+ }
7
+ }
8
+
9
+ provider "consul" {
10
+ address = "127.0.0.1:8500"
11
+ version = "~> 1.0"
12
+ }
13
+
14
+ locals {
15
+ keys = {
16
+ foo = "foo2val"
17
+ bar = "bar2val"
18
+ baz = "baz2val"
19
+ }
20
+ }
21
+
22
+ variable "foo" { default = "bar" }
23
+
24
+ resource "consul_key_prefix" "landscapeTest" {
25
+ invalid_param = "whoCares"
26
+ }
27
+
28
+ output "foo_variable" { value = "${var.foo}" }
@@ -0,0 +1,67 @@
1
+ Terraform v0.11.2
2
+
3
+ Your version of Terraform is out of date! The latest version
4
+ is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
5
+ terraform_runner command: 'terraform init -input=false' (in /home/jantman/manheim/git/github_dot_com/tfwrapper/spec/fixtures/landscapeTest/failingTerraform)
6
+ Running with: Terraform v0.11.2
7
+
8
+ Your version of Terraform is out of date! The latest version
9
+ is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
10
+
11
+ Initializing the backend...
12
+ 
13
+ Successfully configured the backend "consul"! Terraform will automatically
14
+ use this backend unless the backend configuration changes.
15
+
16
+ Initializing provider plugins...
17
+ - Checking for available provider plugins on https://releases.hashicorp.com...
18
+ - Downloading plugin for provider "consul" (1.0.0)...
19
+
20
+ Terraform has been successfully initialized!
21
+ 
22
+ You may now begin working with Terraform. Try running "terraform plan" to see
23
+ any changes that are required for your infrastructure. All Terraform commands
24
+ should now work.
25
+
26
+ If you ever set or change modules or backend configuration for Terraform,
27
+ rerun this command to reinitialize your working directory. If you forget, other
28
+ commands will detect it and remind you to do so if necessary.
29
+ terraform_runner command 'terraform init -input=false' finished and exited 0
30
+ Terraform vars written to: /home/jantman/manheim/git/github_dot_com/tfwrapper/spec/fixtures/landscapeTest/failing_build.tfvars.json
31
+ terraform_runner command: 'terraform plan -var-file /home/jantman/manheim/git/github_dot_com/tfwrapper/spec/fixtures/landscapeTest/failing_build.tfvars.json' (in /home/jantman/manheim/git/github_dot_com/tfwrapper/spec/fixtures/landscapeTest/failingTerraform)
32
+ Terraform vars:
33
+ ............
34
+ Error: consul_key_prefix.landscapeTest: "path_prefix": required field is not set
35
+
36
+ 
37
+ 
38
+ Error: consul_key_prefix.landscapeTest: "subkeys": required field is not set
39
+
40
+ 
41
+ 
42
+ Error: consul_key_prefix.landscapeTest: : invalid or unknown key: invalid_param
43
+
44
+ 
45
+ rake aborted!
46
+ StandardError: Errors have occurred executing: 'terraform plan -var-file /home/jantman/manheim/git/github_dot_com/tfwrapper/spec/fixtures/landscapeTest/failing_build.tfvars.json' (exited 1)
47
+ /home/jantman/manheim/git/github_dot_com/tfwrapper/lib/tfwrapper/raketasks.rb:409:in `terraform_runner'
48
+ /home/jantman/manheim/git/github_dot_com/tfwrapper/lib/tfwrapper/raketasks.rb:202:in `block (2 levels) in install_plan'
49
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `load'
50
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `kernel_load'
51
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:28:in `run'
52
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli.rb:424:in `exec'
53
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
54
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
55
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
56
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli.rb:27:in `dispatch'
57
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
58
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli.rb:18:in `start'
59
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/exe/bundle:30:in `block in <top (required)>'
60
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors'
61
+ /home/jantman/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
62
+ /home/jantman/.rvm/gems/ruby-2.4.1/bin/bundle:23:in `load'
63
+ /home/jantman/.rvm/gems/ruby-2.4.1/bin/bundle:23:in `<main>'
64
+ /home/jantman/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
65
+ /home/jantman/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
66
+ Tasks: TOP => failing_tf:plan
67
+ (See full trace by running task with --trace)
@@ -1,12 +1,12 @@
1
1
  Terraform v0.11.2
2
2
 
3
3
  Your version of Terraform is out of date! The latest version
4
- is 0.11.5. You can update by downloading from www.terraform.io/downloads.html
4
+ is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
5
5
  terraform_runner command: 'terraform init -input=false' (in /home/jantman/manheim/git/github_dot_com/tfwrapper/spec/fixtures/landscapeTest)
6
6
  Running with: Terraform v0.11.2
7
7
 
8
8
  Your version of Terraform is out of date! The latest version
9
- is 0.11.5. You can update by downloading from www.terraform.io/downloads.html
9
+ is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
10
10
 
11
11
  Initializing the backend...
12
12
  
@@ -43,4 +43,3 @@ Terraform vars:
43
43
  }
44
44
 
45
45
  Plan: 0 to add, 1 to change, 0 to destroy.
46
-
@@ -1,12 +1,12 @@
1
1
  Terraform v0.11.2
2
2
 
3
3
  Your version of Terraform is out of date! The latest version
4
- is 0.11.5. You can update by downloading from www.terraform.io/downloads.html
4
+ is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
5
5
  terraform_runner command: 'terraform init -input=false' (in /home/jantman/manheim/git/github_dot_com/tfwrapper/spec/fixtures/landscapeTest)
6
6
  Running with: Terraform v0.11.2
7
7
 
8
8
  Your version of Terraform is out of date! The latest version
9
- is 0.11.5. You can update by downloading from www.terraform.io/downloads.html
9
+ is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
10
10
 
11
11
  Initializing the backend...
12
12
  
@@ -68,4 +68,3 @@ terraform_runner command 'terraform plan -var-file /home/jantman/manheim/git/git
68
68
  }
69
69
 
70
70
  Plan: 0 to add, 1 to change, 0 to destroy.
71
-
@@ -1306,6 +1306,18 @@ describe TFWrapper::RakeTasks do
1306
1306
  expect { subject.terraform_runner('foo') }
1307
1307
  .to raise_error('Errors have occurred executing: \'foo\' (exited 1)')
1308
1308
  end
1309
+ it 'prints output to STDERR if plan exits non-zero and not :stream' do
1310
+ allow(TFWrapper::Helpers).to receive(:run_cmd_stream_output)
1311
+ .and_return(['myoutput', 1])
1312
+ expect(TFWrapper::Helpers).to receive(:run_cmd_stream_output).once
1313
+ .with('foo', 'tfdir', progress: :dots)
1314
+ expect(STDERR).to receive(:puts).once
1315
+ .with('terraform_runner command: \'foo\' (in tfdir)')
1316
+ expect(STDERR).to receive(:puts).once
1317
+ .with('myoutput')
1318
+ expect { subject.terraform_runner('foo', progress: :dots) }
1319
+ .to raise_error('Errors have occurred executing: \'foo\' (exited 1)')
1320
+ end
1309
1321
  it 'raises an error if the progress option is invalid' do
1310
1322
  allow(TFWrapper::Helpers).to receive(:run_cmd_stream_output)
1311
1323
  .and_return(['', 1])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tfwrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jantman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-30 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: retries
@@ -367,8 +367,10 @@ files:
367
367
  - spec/acceptance/consulserver.rb
368
368
  - spec/fixtures/Rakefile
369
369
  - spec/fixtures/landscapeTest/Rakefile
370
+ - spec/fixtures/landscapeTest/failingTerraform/main.tf
370
371
  - spec/fixtures/landscapeTest/main.tf
371
372
  - spec/fixtures/landscapeTest/state.json
373
+ - spec/fixtures/landscapeTest/when_terraform_fails.out
372
374
  - spec/fixtures/landscapeTest/with_landscape_default.out
373
375
  - spec/fixtures/landscapeTest/with_landscape_dots.out
374
376
  - spec/fixtures/landscapeTest/with_landscape_lines.out
@@ -406,7 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
406
408
  version: '0'
407
409
  requirements: []
408
410
  rubyforge_project:
409
- rubygems_version: 2.5.2
411
+ rubygems_version: 2.6.13
410
412
  signing_key:
411
413
  specification_version: 4
412
414
  summary: Rake tasks for running Hashicorp Terraform sanely
@@ -416,8 +418,10 @@ test_files:
416
418
  - spec/acceptance/consulserver.rb
417
419
  - spec/fixtures/Rakefile
418
420
  - spec/fixtures/landscapeTest/Rakefile
421
+ - spec/fixtures/landscapeTest/failingTerraform/main.tf
419
422
  - spec/fixtures/landscapeTest/main.tf
420
423
  - spec/fixtures/landscapeTest/state.json
424
+ - spec/fixtures/landscapeTest/when_terraform_fails.out
421
425
  - spec/fixtures/landscapeTest/with_landscape_default.out
422
426
  - spec/fixtures/landscapeTest/with_landscape_dots.out
423
427
  - spec/fixtures/landscapeTest/with_landscape_lines.out