tfoutputs 0.1.1 → 0.2.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/.travis.yml +7 -0
- data/CHANGELOG.md +12 -0
- data/README.md +2 -0
- data/lib/tfoutputs/configurator/backends/file_state_configuration.rb +15 -0
- data/lib/tfoutputs/configurator/backends/s3_state_configuration.rb +26 -0
- data/lib/tfoutputs/configurator/state_configurator.rb +6 -6
- data/lib/tfoutputs/configurator/state_reader.rb +9 -1
- data/lib/tfoutputs/configurator/version.rb +1 -1
- data/tfoutputs.gemspec +1 -2
- metadata +7 -19
- data/lib/tfoutputs/configurator/file_state_configuration.rb +0 -13
- data/lib/tfoutputs/configurator/s3_state_configuration.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a1418f14ee8f29596ee75dfd660b0a16159768c
|
4
|
+
data.tar.gz: 3e95c39c5b73b8a02d0a42c306817e840f360df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac6cd4d0df5f5b2d97552c422a072b5b8d8fb7e9538616537d24bf79e57ef98fffbc58f9bebd61bfaebb0f6632835f57d87a619899156569f6eac863d32a528d
|
7
|
+
data.tar.gz: 13eef4db648d1ece1b19207947f6bf8bb65845f2d8898d13697a898d553fa3d0074c4052fed11c4d4ff00d592a7819e6307a0f9529b4b37750748a3beb713a0b
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -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
|
+
 [](https://badge.fury.io/rb/tfoutputs)
|
10
|
+
|
9
11
|
|
10
12
|
# Ruby TF Outputs
|
11
13
|
|
@@ -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: '
|
9
|
-
file: '
|
6
|
+
BACKENDS = { s3: 'S3StateConfiguration',
|
7
|
+
file: 'FileStateConfiguration' }.freeze
|
10
8
|
|
11
|
-
|
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
|
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']
|
data/tfoutputs.gemspec
CHANGED
@@ -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://
|
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.
|
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-
|
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://
|
135
|
+
homepage: https://github.com/jae2/ruby-tfoutputs
|
148
136
|
licenses:
|
149
137
|
- MIT
|
150
138
|
metadata: {}
|
@@ -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
|