hiera-router 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiera/backend/router_backend.rb +7 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86e443c63237be161b1bce49efb771b5db93db81
|
4
|
+
data.tar.gz: be04264990b7d1e46066159b5fb0d827ab66ee6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00c455756502f060cebd6b4ca4db44bdb62f347bdcacb306c03149bc10ba11c3d6c12f38da82efb1b20cdd50525e1fd1efbb0dce6d4a0f155e9103fd07b3249
|
7
|
+
data.tar.gz: 4d1d5ade097c65ca9ca513e2b932011bad10bc36f5128fa1c7f589c1242648abe7bb13a6051a1fa2f7bc341eb07c7ebe05a53a50e41c7500b0337457e1558e92
|
@@ -19,7 +19,7 @@ class Hiera
|
|
19
19
|
@cache = cache || Filecache.new
|
20
20
|
@backends = {}
|
21
21
|
Hiera.debug("[hiera-router] I'm here!")
|
22
|
-
config = Config.config
|
22
|
+
self.config = Config.config
|
23
23
|
|
24
24
|
if backend_list = Config[:router][:backends]
|
25
25
|
Hiera.debug("[hiera-router] Initializing backends: #{backend_list.keys.join(',')}")
|
@@ -61,24 +61,18 @@ class Hiera
|
|
61
61
|
Hiera.debug("[hiera-router] Looking up #{key} in yaml backend")
|
62
62
|
|
63
63
|
Backend.datasources(scope, order_override) do |source|
|
64
|
-
Hiera.debug("[hiera-router] Looking for data source #{source}")
|
65
64
|
yaml_file = Backend.datafile(:router, scope, source, 'yaml') || next
|
66
65
|
|
67
|
-
next unless File.exists?(yaml_file)
|
68
|
-
|
69
66
|
data = @cache.read(yaml_file, Hash) do |cached_data|
|
70
67
|
begin
|
71
|
-
|
68
|
+
Hiera.debug("[hiera-router] Looking + loading data source #{source} ('#{yaml_file}')")
|
69
|
+
YAML.load(cached_data) || {}
|
72
70
|
rescue
|
73
|
-
|
71
|
+
Hiera.debug("[hiera-router] something wrong with source #{source} '#{yaml_file}' -- returning an empty result")
|
72
|
+
{}
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
77
|
-
if data.nil?
|
78
|
-
Hiera.debug("[hiera-router] something wrong with source #{source} '#{yaml_file}' -- returning an empty result")
|
79
|
-
next
|
80
|
-
end
|
81
|
-
|
82
76
|
next if data.empty?
|
83
77
|
next unless data.include?(key)
|
84
78
|
|
@@ -148,12 +142,12 @@ class Hiera
|
|
148
142
|
backend_options = options
|
149
143
|
backend_options = backend_options.merge(backend_parameters) if backend_parameters
|
150
144
|
Hiera.debug("[hiera-router] Calling hiera with '#{backend_name}'...")
|
151
|
-
if backend = backends[backend_name.to_sym]
|
145
|
+
if backend = self.backends[backend_name.to_sym]
|
152
146
|
backend_instance = backend[:instance]
|
153
147
|
Hiera.debug("[hiera-router] Backend class: #{backend_instance.class.name}")
|
154
148
|
Config.load(backend[:config])
|
155
149
|
result = backend_instance.lookup(backend_options[:key], backend_options[:scope], nil, backend_options[:resolution_type])
|
156
|
-
Config.load(config)
|
150
|
+
Config.load(self.config)
|
157
151
|
else
|
158
152
|
Hiera.warn "Backend '#{backend_name}' was not configured; returning the data as-is."
|
159
153
|
result = data
|