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 +4 -4
- data/lib/prospectus_terraform.rb +1 -0
- data/lib/prospectus_terraform/modules.rb +69 -0
- data/prospectus_terraform.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fcdd76d53a09fa38c96688fd90fa815d3b29adef2ac099ad8be45688fee184f
|
4
|
+
data.tar.gz: 68f135644babae57ab8fb1278715d95c4cd31d076fbd2916d3249731d41a201a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e7351ead1fb8d43c17e5818742bb26ba5d5818f83bc80b88cb8ee2fc9399fe57a6e9bb95bf8b593ec9dde2195ee2dde5dd66fde25cd90ad2a6a4bbeb2c1f035
|
7
|
+
data.tar.gz: c44ded29039a2d84615ffae7990fe37437ee6eb9491f4aac5e8177474971859e3282af4bfb00282f7d7ea75f89984c93433a8e1f795819fa5dfa92059e752e5d
|
data/lib/prospectus_terraform.rb
CHANGED
@@ -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
|
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
|
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-
|
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
|