terraform_inventory 0.1.4 → 0.1.5
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abd25bd20c539da7650fafbb91f7a1ba6a03c8ad
|
4
|
+
data.tar.gz: dcb41b0e396f7568f352dcae2dc13e1db7ad3ba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 814b0808c1f272484791dc51e14dea04504543c6d512591c5301a356d5a7d4e54fba7d45746efc06548356b250eab5bba752b1f54bcb1b027c3df4ba4952f0a7
|
7
|
+
data.tar.gz: 12ccc784403af83cee86f4d5821e2b8c2cd1e633750c1ca8e6c04fff9ba46eeee1f075136844b37029fdcc970c5ccbbbbaa294efcc67e444cbb0bc754816808e
|
data/bin/tinventory
CHANGED
File without changes
|
@@ -24,8 +24,8 @@ module TerraformInventory
|
|
24
24
|
|
25
25
|
begin
|
26
26
|
@groups = state.group_by_host(options[:map])
|
27
|
-
rescue Exception =>
|
28
|
-
|
27
|
+
rescue Exception::InvalidResourceSelectorException, Exception::ResourceNotFoundException => ex
|
28
|
+
say ex.message, :red
|
29
29
|
exit(1)
|
30
30
|
else
|
31
31
|
@ungrouped_resources = @groups[:none] || []
|
@@ -20,7 +20,7 @@ module TerraformInventory
|
|
20
20
|
def find_resources(resource_selector)
|
21
21
|
resource_type, resource_name, resource_number = parse_resource_selector(resource_selector)
|
22
22
|
|
23
|
-
if @state[resource_type][resource_name].nil?
|
23
|
+
if @state[resource_type].nil? || @state[resource_type][resource_name].nil?
|
24
24
|
[]
|
25
25
|
elsif resource_number
|
26
26
|
[@state[resource_type][resource_name][resource_number]]
|
@@ -34,9 +34,7 @@ module TerraformInventory
|
|
34
34
|
data[host_group.to_sym] ||= []
|
35
35
|
resources = find_resources(resource_selector)
|
36
36
|
|
37
|
-
|
38
|
-
raise "Resources matching resource_selector '#{resource_selector}' not found."
|
39
|
-
end
|
37
|
+
raise Exception::ResourceNotFoundException, resource_selector if resources.empty?
|
40
38
|
|
41
39
|
data[host_group.to_sym].concat resources
|
42
40
|
data
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "terraform_inventory/exception"
|
2
3
|
|
3
4
|
# rubocop:disable Style/TrailingWhitespace
|
4
5
|
terraform_show_output = %(
|
@@ -48,6 +49,18 @@ describe TerraformInventory::TerraformState do
|
|
48
49
|
let(:state) { TerraformInventory::TerraformState.new terraform_show_output }
|
49
50
|
|
50
51
|
describe "#find_resource" do
|
52
|
+
context "using an invalid resource_selector" do
|
53
|
+
it "throws a TerraformInventory::Exception::InvalidResourceSelectorException" do
|
54
|
+
begin
|
55
|
+
state.find_resources("aws_instance_invalid!!!!web")
|
56
|
+
rescue TerraformInventory::Exception::InvalidResourceSelectorException
|
57
|
+
next
|
58
|
+
else
|
59
|
+
raise "This should have raised a TerraformInventory::Exception::InvalidResourceSelectorException"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
51
64
|
context "using a resource_selector without resource_number" do
|
52
65
|
let(:resources) { state.find_resources("aws_instance.web") }
|
53
66
|
|
@@ -89,13 +102,13 @@ describe TerraformInventory::TerraformState do
|
|
89
102
|
end
|
90
103
|
|
91
104
|
context "when a resource_selector isn't found" do
|
92
|
-
it "throws
|
105
|
+
it "throws a TerraformInventory::Exception::ResourceNotFoundException" do
|
93
106
|
begin
|
94
107
|
state.group_by_host Hash["aws_instance.freeswitch", "freeswitch"]
|
95
|
-
rescue
|
108
|
+
rescue TerraformInventory::Exception::ResourceNotFoundException
|
96
109
|
next
|
97
110
|
else
|
98
|
-
raise "This should have raised
|
111
|
+
raise "This should have raised a TerraformInventory::Exception::ResourceNotFoundException"
|
99
112
|
end
|
100
113
|
end
|
101
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraform_inventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Cross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|