prospectus_terraform 0.0.3 → 0.1.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
  SHA256:
3
- metadata.gz: bffd7aeae7dd47161b99cfbad8cafc240a0e45bfc5b22778ec56898a89242852
4
- data.tar.gz: cfd5f2adcb9f10103a7dd7419679c2d0021a1026c68416c6704ae1e35e6aae7a
3
+ metadata.gz: 3fcdd76d53a09fa38c96688fd90fa815d3b29adef2ac099ad8be45688fee184f
4
+ data.tar.gz: 68f135644babae57ab8fb1278715d95c4cd31d076fbd2916d3249731d41a201a
5
5
  SHA512:
6
- metadata.gz: 32ddb4bbde8aa85528b463b8e1cbc97371fd3b7d2f63249cc9b2f976f0d974ff5fe5f42e754c8efc6ce91d3748cf100458c0172c93a7570268a979bf235066fb
7
- data.tar.gz: a94b63ba49ae777c91cf1cf471a081f5627391ecc92ae6cbcb58936d962fadfeb8436f25540dbe0e40203166eafd6b94634d7f3f279388de930e0ec5d2b2a7bc
6
+ metadata.gz: 3e7351ead1fb8d43c17e5818742bb26ba5d5818f83bc80b88cb8ee2fc9399fe57a6e9bb95bf8b593ec9dde2195ee2dde5dd66fde25cd90ad2a6a4bbeb2c1f035
7
+ data.tar.gz: c44ded29039a2d84615ffae7990fe37437ee6eb9491f4aac5e8177474971859e3282af4bfb00282f7d7ea75f89984c93433a8e1f795819fa5dfa92059e752e5d
@@ -1 +1,2 @@
1
1
  require 'prospectus_terraform/providers'
2
+ require 'prospectus_terraform/modules'
@@ -0,0 +1,69 @@
1
+ require 'open3'
2
+ require 'open-uri'
3
+
4
+ module ProspectusTerraform
5
+ ##
6
+ # Module object, for passing state and update info
7
+ class ModuleData
8
+ attr_reader :name, :version
9
+
10
+ def initialize(params)
11
+ @name = params['source']
12
+ @version = params['version']
13
+ end
14
+
15
+ def latest
16
+ resp = JSON.parse(open(latest_url).read) # rubocop:disable Security/Open
17
+ resp['version']
18
+ end
19
+
20
+ private
21
+
22
+ def latest_url
23
+ @latest_url ||= 'https://registry.terraform.io/v1/modules/' + name
24
+ end
25
+ end
26
+
27
+ ##
28
+ # Helper for automatically adding module status check
29
+ class Modules < Module
30
+ def extended(other) # rubocop:disable Metrics/MethodLength
31
+ modules_object = modules
32
+
33
+ other.deps do
34
+ modules_object.each do |m|
35
+ item do
36
+ name "module-#{m.name}"
37
+
38
+ expected do
39
+ static
40
+ set m.latest
41
+ end
42
+
43
+ actual do
44
+ static
45
+ set m.version
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ def config_json
53
+ return @config_json if @config_json
54
+ stdout, stderr, status = Open3.capture3(cmd_name)
55
+ raise("#{cmd_name} failed") unless status.success? && stderr.empty?
56
+ @config_json = stdout
57
+ end
58
+
59
+ def cmd_name
60
+ 'terraform-config-inspect --json'
61
+ end
62
+
63
+ def modules
64
+ @modules ||= JSON.parse(config_json)['module_calls'].values.map do |x|
65
+ ModuleData.new(x)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'prospectus_terraform'
3
- s.version = '0.0.3'
3
+ s.version = '0.1.0'
4
4
  s.date = Time.now.strftime('%Y-%m-%d')
5
5
 
6
6
  s.summary = 'Prospectus helpers for Terraform'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prospectus_terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-05 00:00:00.000000000 Z
11
+ date: 2019-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prospectus
@@ -125,6 +125,7 @@ files:
125
125
  - README.md
126
126
  - Rakefile
127
127
  - lib/prospectus_terraform.rb
128
+ - lib/prospectus_terraform/modules.rb
128
129
  - lib/prospectus_terraform/providers.rb
129
130
  - prospectus_terraform.gemspec
130
131
  - spec/prospectus_terraform_spec.rb