tfwrapper 0.2.0.beta1 → 0.2.0

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: 0d770015f26d1cc19424567299a4cf0d300c7c9d
4
- data.tar.gz: 682aecc64e4c300ff15140221f7b69b47a7042d1
3
+ metadata.gz: 546f4a0d5cfe06c3e1606071f6c09c74752d6ef0
4
+ data.tar.gz: 52178cde8c11eed2bed48df05c086ef9517d62c6
5
5
  SHA512:
6
- metadata.gz: 0501b6c78f2c23afc807ab5f2942798929d177fdfd07230504135c5470360655bd5705c6b4086977b763f6337d0a5dc28d997c816d78519e1b0bef8c1243db4c
7
- data.tar.gz: 2361518650e15fef68dab14983345195935b8a46bdd2fd88dc1c8a70813140a5f43ba57781efed2a0ce79e79867dda1e950e340bfe8e51d47feacf1e381ef449
6
+ metadata.gz: 296ea36c9f2c02ebe4fed3b94bd69f3e47bb31f938980e8b96ff7d2528e1b2db63d9d9934394cb2a3fdb83bda0507cdaa238ec6425fe8830d4466c6097704fce
7
+ data.tar.gz: 4d2ac178cdd25438debf5add32f007f76d1ca99b23d04dfa29e26d90ef1d819c8ceb6172e6f4c93e09893daa1ca02ccb4fa2ae2dd1e70d9cab09b79baa0281c1
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
- Version 0.1.0
1
+ Version 0.2.0
2
2
 
3
3
  - initial release (migrated from previous internal/private gem)
4
+
5
+ Version 0.1.0
6
+
7
+ - no working public release
data/README.md CHANGED
@@ -40,7 +40,7 @@ with 1.9.3 is simply too high to justify.
40
40
  Add to your ``Gemfile``:
41
41
 
42
42
  ```ruby
43
- gem 'tfwrapper', '~> 0.1.0'
43
+ gem 'tfwrapper', '~> 0.2.0'
44
44
  ```
45
45
 
46
46
  ### Supported Terraform Versions
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TFWrapper
4
- # version of the Gem/module; used in the gemspec and in messages
5
- VERSION = '0.2.0.beta1'
4
+ # version of the Gem/module; used in the gemspec and in messages.
5
+ # NOTE: When updating this, also update the version in the "Installation"
6
+ # section of README.md
7
+ VERSION = '0.2.0'
6
8
  end
@@ -120,7 +120,10 @@ describe 'tfwrapper' do
120
120
  )
121
121
  ENV['FOO'] = 'fooval'
122
122
  end
123
- after(:all) { ENV.delete('FOO') }
123
+ after(:all) do
124
+ ENV.delete('FOO')
125
+ ENV.delete('TFSUFFIX')
126
+ end
124
127
  describe 'rake -T' do
125
128
  before(:all) do
126
129
  @out_err, @ecode = Open3.capture2e(
@@ -155,8 +158,69 @@ describe 'tfwrapper' do
155
158
  expect(@out_err).to include('rake tf:write_tf_vars')
156
159
  end
157
160
  end
158
- describe 'tf:apply' do
161
+ describe 'tf:apply foo' do
162
+ before(:all) do
163
+ Diplomat::Kv.get('/', keys: true).each { |k| Diplomat::Kv.delete(k) }
164
+ ENV['TFSUFFIX'] = 'foo'
165
+ @out_err, @ecode = Open3.capture2e(
166
+ 'timeout -k 60 45 bundle exec rake tf:apply',
167
+ chdir: @fixturepath
168
+ )
169
+ @varpath = File.join(@fixturepath, 'build.tfvars.json')
170
+ end
171
+ after(:all) do
172
+ File.delete(@varpath) if File.file?(@varpath)
173
+ end
174
+ it 'does not time out' do
175
+ expect(@ecode.exitstatus).to_not eq(124)
176
+ expect(@ecode.exitstatus).to_not eq(137)
177
+ end
178
+ it 'exits zero' do
179
+ expect(@ecode.exitstatus).to eq(0)
180
+ end
181
+ it 'uses the correct Terraform version' do
182
+ expect(@out_err).to include("Terraform v#{TF_VERSION}")
183
+ end
184
+ it 'runs apply correctly and succeeds' do
185
+ expect(@out_err)
186
+ .to include('terraform_runner command: \'terraform apply -var-file')
187
+ expect(@out_err).to include('consul_keys.testTwo: Creating...')
188
+ expect(@out_err).to include(
189
+ 'Apply complete! Resources: 1 added, 0 changed, 0 destroyed.'
190
+ )
191
+ expect(@out_err).to include(
192
+ "Outputs:\n\nbar_variable = barval\nfoo_variable = fooval"
193
+ )
194
+ end
195
+ it 'writes the vars file' do
196
+ expect(File.file?(@varpath)).to be(true)
197
+ c = File.open(@varpath, 'r').read
198
+ expect(JSON.parse(c))
199
+ .to eq('foo' => 'fooval', 'bar' => 'barval')
200
+ end
201
+ it 'sets the consul keys' do
202
+ expect(Diplomat::Kv.get('testTwo/foo')).to eq('fooval')
203
+ expect(Diplomat::Kv.get('testTwo/bar')).to eq('barval')
204
+ end
205
+ it 'writes remote state to consul' do
206
+ state = JSON.parse(Diplomat::Kv.get('terraform/testTwo/foo'))
207
+ expect(state['version']).to eq(3)
208
+ expect(state['terraform_version']).to eq(TF_VERSION)
209
+ expect(state['serial']).to eq(1)
210
+ expect(state['modules'].length).to eq(1)
211
+ expect(state['modules'][0]['outputs']['foo_variable']['value'])
212
+ .to eq('fooval')
213
+ expect(state['modules'][0]['outputs']['bar_variable']['value'])
214
+ .to eq('barval')
215
+ expect(state['modules'][0]['resources'])
216
+ .to include('consul_keys.testTwo')
217
+ expect(state['modules'][0]['resources'].length).to eq(1)
218
+ end
219
+ end
220
+ describe 'tf:apply bar' do
159
221
  before(:all) do
222
+ Diplomat::Kv.get('/', keys: true).each { |k| Diplomat::Kv.delete(k) }
223
+ ENV['TFSUFFIX'] = 'bar'
160
224
  @out_err, @ecode = Open3.capture2e(
161
225
  'timeout -k 60 45 bundle exec rake tf:apply',
162
226
  chdir: @fixturepath
@@ -198,7 +262,7 @@ describe 'tfwrapper' do
198
262
  expect(Diplomat::Kv.get('testTwo/bar')).to eq('barval')
199
263
  end
200
264
  it 'writes remote state to consul' do
201
- state = JSON.parse(Diplomat::Kv.get('terraform/testTwo'))
265
+ state = JSON.parse(Diplomat::Kv.get('terraform/testTwo/bar'))
202
266
  expect(state['version']).to eq(3)
203
267
  expect(state['terraform_version']).to eq(TF_VERSION)
204
268
  expect(state['serial']).to eq(1)
@@ -4,6 +4,9 @@ require 'tfwrapper/raketasks'
4
4
 
5
5
  TFWrapper::RakeTasks.install_tasks(
6
6
  'foo/bar',
7
+ backend_config: {
8
+ 'path' => "terraform/testTwo/#{ENV['TFSUFFIX']}"
9
+ },
7
10
  tf_vars_from_env: { 'foo' => 'FOO' },
8
11
  tf_extra_vars: { 'bar' => 'barval' }
9
12
  )
@@ -2,7 +2,6 @@ terraform {
2
2
  required_version = "> 0.9.0"
3
3
  backend "consul" {
4
4
  address = "127.0.0.1:8500"
5
- path = "terraform/testTwo"
6
5
  }
7
6
  }
8
7
 
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.2.0.beta1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jantman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-03 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: retries
@@ -393,9 +393,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
393
393
  version: 2.0.0
394
394
  required_rubygems_version: !ruby/object:Gem::Requirement
395
395
  requirements:
396
- - - ">"
396
+ - - ">="
397
397
  - !ruby/object:Gem::Version
398
- version: 1.3.1
398
+ version: '0'
399
399
  requirements: []
400
400
  rubyforge_project:
401
401
  rubygems_version: 2.5.2