tfoutputs 0.1.1 → 0.2.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: 0d1f519f69a2617bb93343edad27b1ebbc412363
4
- data.tar.gz: 3c17ea150793faa27f730a015c89ca8e14fd3512
3
+ metadata.gz: 1a1418f14ee8f29596ee75dfd660b0a16159768c
4
+ data.tar.gz: 3e95c39c5b73b8a02d0a42c306817e840f360df3
5
5
  SHA512:
6
- metadata.gz: 74e2f00ce1c15b3393ef111e8a1a5fbb179a28669c52cdc7294f5e3bf8c56dd0ca45765bdfc2ac1b8c9c2646cd300d8f381c81c85b8f6997b3ebd17bc08063dc
7
- data.tar.gz: d025fe9843ee9013bbf253344cfcb58c9bce597081de440a3ff6e930f94102c1a77167917eba62dedc4121077326b0e8555cec5b1b685319fb325f02de99aa96
6
+ metadata.gz: ac6cd4d0df5f5b2d97552c422a072b5b8d8fb7e9538616537d24bf79e57ef98fffbc58f9bebd61bfaebb0f6632835f57d87a619899156569f6eac863d32a528d
7
+ data.tar.gz: 13eef4db648d1ece1b19207947f6bf8bb65845f2d8898d13697a898d553fa3d0074c4052fed11c4d4ff00d592a7819e6307a0f9529b4b37750748a3beb713a0b
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ - 2.3.0
5
+ script: bundle exec rake spec
6
+ env:
7
+ - AWS_ACCESS_KEY=foo AWS_SECRET_ACCESS_KEY=bar
@@ -0,0 +1,12 @@
1
+
2
+ ## Version 0.2.1
3
+ This release includes:
4
+ - Fix backend loading: [PR #4](https://github.com/jae2/ruby-tfoutputs/pull/4) - Thanks @patdowney
5
+
6
+ ## Version 0.2.0 - BROKEN RELEASE
7
+
8
+ This release includes:
9
+ - Removal of activestate gem - [PR #2](https://github.com/jae2/ruby-tfoutputs/pull/2) Thanks @patdowney
10
+ - inclusion of respond_to? method - [PR #3](https://github.com/jae2/ruby-tfoutputs/pull/2)
11
+
12
+
data/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
  /_/ |_|\__,_/_.___/\__, / /_/ /_/ \____/\__,_/\__/ .___/\__,_/\__/____/
7
7
  /____/ /_/
8
8
  ```
9
+ ![build status on master](https://travis-ci.org/jae2/ruby-tfoutputs.svg?branch=master) [![Gem Version](https://badge.fury.io/rb/tfoutputs.svg)](https://badge.fury.io/rb/tfoutputs)
10
+
9
11
 
10
12
  # Ruby TF Outputs
11
13
 
@@ -0,0 +1,15 @@
1
+ module TfOutputs
2
+ module Configurator
3
+ module Backends
4
+ class FileStateConfiguration
5
+ def initialize(options)
6
+ @options = options
7
+ end
8
+
9
+ def save
10
+ File.new (@options[:file_path])
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ require 'aws-sdk'
2
+ require 'tempfile'
3
+
4
+ module TfOutputs
5
+ module Configurator
6
+ module Backends
7
+ class S3StateConfiguration
8
+ :attr_accessor
9
+ def initialize(options)
10
+ @bucket_name = options[:bucket_name]
11
+ @bucket_key = options[:bucket_key]
12
+ @bucket_region = options[:bucket_region]
13
+ end
14
+
15
+ def save
16
+ file = Tempfile.new('tf_state')
17
+ s3 = Aws::S3::Client.new(region: @bucket_region)
18
+ resp = s3.get_object bucket: @bucket_name, key: @bucket_key
19
+ file.write(resp.body.string)
20
+ file.rewind
21
+ file
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,14 +1,14 @@
1
- require 'active_support/inflector'
2
-
3
1
  module TfOutputs
4
2
  module Configurator
5
3
  class StateConfigurator
6
4
  attr_accessor :state_uris
7
5
 
8
- BACKENDS = { s3: 's3_state_configuration',
9
- file: 'file_state_configuration' }.freeze
6
+ BACKENDS = { s3: 'S3StateConfiguration',
7
+ file: 'FileStateConfiguration' }.freeze
10
8
 
11
- BACKENDS.each { |_backend, filename| require "tfoutputs/configurator/#{filename}" }
9
+ Dir.glob("#{File.dirname(__FILE__)}/backends/*").each do |filename|
10
+ require_relative "backends/#{File.basename(filename)}"
11
+ end
12
12
 
13
13
  def initialize(states_array)
14
14
  @states_array = states_array
@@ -19,7 +19,7 @@ module TfOutputs
19
19
  @states_array.each do |state_hash|
20
20
  backend_name = state_hash[:backend]
21
21
  class_name = BACKENDS[backend_name.to_sym]
22
- clazz = Object.const_get("TfOutputs::Configurator::#{class_name.camelize}")
22
+ clazz = Object.const_get("TfOutputs::Configurator::Backends::#{class_name}")
23
23
  state = clazz.new (state_hash[:options])
24
24
  file_list.push(state.save)
25
25
  end
@@ -24,7 +24,6 @@ module TfOutputs
24
24
  end
25
25
 
26
26
  protected
27
-
28
27
  def parse_outputs(tf_module)
29
28
  if tf_module['path'] == ['root']
30
29
  tf_module['outputs'].collect do |k, v|
@@ -34,7 +33,16 @@ module TfOutputs
34
33
  end
35
34
  end
36
35
 
36
+ def respond_to? (method, include_private = false)
37
+ outputs.each do |output|
38
+ next unless output.keys[0] == method.to_s
39
+ return true
40
+ end
41
+ super
42
+ end
43
+
37
44
  def method_missing(name, *args, &block)
45
+ # Hack - really we should call respond_to?
38
46
  outputs.each do |output|
39
47
  next unless output.keys[0] == name.to_s
40
48
  return 'sensitive' if output[name.to_s]['sensitive']
@@ -1,5 +1,5 @@
1
1
  module TfOutputs
2
2
  module Configurator
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = 'Gem for grabbing variables from terraform'
13
13
  spec.description = 'Sometimes we want to use the outputs of terraform in our ruby code for generating dashboard etc.. This gem enables this'
14
- spec.homepage = 'https://jaetech.org'
14
+ spec.homepage = 'https://github.com/jae2/ruby-tfoutputs'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|fixtures)/}) }
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'rake', '~> 10.0'
22
22
  spec.add_development_dependency 'rubocop'
23
23
  spec.add_runtime_dependency 'aws-sdk', '~> 2'
24
- spec.add_runtime_dependency 'activesupport', '~> 5'
25
24
  spec.add_development_dependency 'rspec', '~> 3.5'
26
25
  spec.add_development_dependency 'vcr', '~>3.0'
27
26
  spec.add_development_dependency 'webmock', '~> 2.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tfoutputs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Edwards
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-19 00:00:00.000000000 Z
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2'
69
- - !ruby/object:Gem::Dependency
70
- name: activesupport
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '5'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '5'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -131,20 +117,22 @@ extensions: []
131
117
  extra_rdoc_files: []
132
118
  files:
133
119
  - ".gitignore"
120
+ - ".travis.yml"
121
+ - CHANGELOG.md
134
122
  - CODE_OF_CONDUCT.md
135
123
  - Gemfile
136
124
  - LICENSE.txt
137
125
  - README.md
138
126
  - Rakefile
139
127
  - lib/tfoutputs.rb
140
- - lib/tfoutputs/configurator/file_state_configuration.rb
141
- - lib/tfoutputs/configurator/s3_state_configuration.rb
128
+ - lib/tfoutputs/configurator/backends/file_state_configuration.rb
129
+ - lib/tfoutputs/configurator/backends/s3_state_configuration.rb
142
130
  - lib/tfoutputs/configurator/state_configurator.rb
143
131
  - lib/tfoutputs/configurator/state_reader.rb
144
132
  - lib/tfoutputs/configurator/version.rb
145
133
  - lib/tfoutputs/tooling/vcr_redacter.rb
146
134
  - tfoutputs.gemspec
147
- homepage: https://jaetech.org
135
+ homepage: https://github.com/jae2/ruby-tfoutputs
148
136
  licenses:
149
137
  - MIT
150
138
  metadata: {}
@@ -1,13 +0,0 @@
1
- module TfOutputs
2
- module Configurator
3
- class FileStateConfiguration
4
- def initialize(options)
5
- @options = options
6
- end
7
-
8
- def save
9
- File.new (@options[:file_path])
10
- end
11
- end
12
- end
13
- end
@@ -1,24 +0,0 @@
1
- require 'aws-sdk'
2
- require 'tempfile'
3
-
4
- module TfOutputs
5
- module Configurator
6
- class S3StateConfiguration
7
- :attr_accessor
8
- def initialize(options)
9
- @bucket_name = options[:bucket_name]
10
- @bucket_key = options[:bucket_key]
11
- @bucket_region = options[:bucket_region]
12
- end
13
-
14
- def save
15
- file = Tempfile.new('tf_state')
16
- s3 = Aws::S3::Client.new(region: @bucket_region)
17
- resp = s3.get_object bucket: @bucket_name, key: @bucket_key
18
- file.write(resp.body.string)
19
- file.rewind
20
- file
21
- end
22
- end
23
- end
24
- end