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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 270b051d6714ab746076bb4fb1cd045e6bac9bb3
4
- data.tar.gz: bbd6acc88db52a5a3db6cc6617c549b87dba46f1
3
+ metadata.gz: 86e443c63237be161b1bce49efb771b5db93db81
4
+ data.tar.gz: be04264990b7d1e46066159b5fb0d827ab66ee6f
5
5
  SHA512:
6
- metadata.gz: 4d1466d75a15d0080abb23c4d6525415ff43dbfd0f44bc89b2410079d787cb1d11037bbc361da01bb13508c65f643cf42be372daa4d4bcbf7c23f50d001a5b24
7
- data.tar.gz: 5bd9826ece5fc3c2e019902d5f8a901e3a1bb04c2aa7f802dea0407641b6ed62e382ff807a389210fb036885f94bcfe6cc037fba992e80f613554c58f066866b
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
- YAML.load(cached_data)
68
+ Hiera.debug("[hiera-router] Looking + loading data source #{source} ('#{yaml_file}')")
69
+ YAML.load(cached_data) || {}
72
70
  rescue
73
- nil
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Vandeginste