tfwrapper 0.5.0 → 0.5.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.
- checksums.yaml +4 -4
- data/ChangeLog.md +4 -0
- data/README.md +1 -1
- data/lib/tfwrapper/raketasks.rb +2 -0
- data/lib/tfwrapper/version.rb +1 -1
- data/spec/acceptance/acceptance_spec.rb +28 -0
- data/spec/fixtures/landscapeTest/Rakefile +6 -0
- data/spec/fixtures/landscapeTest/failingTerraform/main.tf +28 -0
- data/spec/fixtures/landscapeTest/when_terraform_fails.out +67 -0
- data/spec/fixtures/landscapeTest/with_landscape_dots.out +2 -3
- data/spec/fixtures/landscapeTest/with_landscape_lines.out +2 -3
- data/spec/unit/raketasks_spec.rb +12 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c135173a4a6dbe8d20af3194d7709464d55f1cae
|
4
|
+
data.tar.gz: 1e8916123d75be89c7cac726147245412a334fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e2429724f5641075d767180b3bb62f738188604a94d8bd435279c979773469c07fcb78672d8c291a570efdab38610d7492db9074aeab0c4e4d80c3573f8ecae
|
7
|
+
data.tar.gz: 69fbef7e6e4daf1ff99136bc9aad1963edb3f5ad86d3adcff88b589b4094c17874e9bf324b5a3b83cd2b0afff2407a178bc9c7b7ea20f3aff1d38c79f9b07be6
|
data/ChangeLog.md
CHANGED
data/README.md
CHANGED
data/lib/tfwrapper/raketasks.rb
CHANGED
@@ -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
|
data/lib/tfwrapper/version.rb
CHANGED
@@ -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
|
@@ -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
|
+
[0m[1mInitializing the backend...[0m
|
12
|
+
[0m[32m
|
13
|
+
Successfully configured the backend "consul"! Terraform will automatically
|
14
|
+
use this backend unless the backend configuration changes.[0m
|
15
|
+
|
16
|
+
[0m[1mInitializing provider plugins...[0m
|
17
|
+
- Checking for available provider plugins on https://releases.hashicorp.com...
|
18
|
+
- Downloading plugin for provider "consul" (1.0.0)...
|
19
|
+
|
20
|
+
[0m[1m[32mTerraform has been successfully initialized![0m[32m[0m
|
21
|
+
[0m[32m
|
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.[0m
|
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
|
+
............[31m
|
34
|
+
[1m[31mError: [0m[0m[1mconsul_key_prefix.landscapeTest: "path_prefix": required field is not set[0m
|
35
|
+
|
36
|
+
[0m[0m[0m
|
37
|
+
[31m
|
38
|
+
[1m[31mError: [0m[0m[1mconsul_key_prefix.landscapeTest: "subkeys": required field is not set[0m
|
39
|
+
|
40
|
+
[0m[0m[0m
|
41
|
+
[31m
|
42
|
+
[1m[31mError: [0m[0m[1mconsul_key_prefix.landscapeTest: : invalid or unknown key: invalid_param[0m
|
43
|
+
|
44
|
+
[0m[0m[0m
|
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
|
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
|
9
|
+
is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
|
10
10
|
|
11
11
|
[0m[1mInitializing the backend...[0m
|
12
12
|
[0m[32m
|
@@ -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
|
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
|
9
|
+
is %%TF_LATEST_VER%%. You can update by downloading from www.terraform.io/downloads.html
|
10
10
|
|
11
11
|
[0m[1mInitializing the backend...[0m
|
12
12
|
[0m[32m
|
@@ -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
|
-
|
data/spec/unit/raketasks_spec.rb
CHANGED
@@ -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.
|
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
|
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.
|
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
|