hiera-router 0.2.6.1 → 0.3.0
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 +37 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abfcfa47f33ef9e671eb2ae5c67a926ff54e9ece
|
4
|
+
data.tar.gz: 08d87376e47464ef8d8950d904049e7b6984f3d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b590110177566923f3ae58051ebbbd224b3a5a50845425e92bae141510eae919f07c2ae93a00b3d6e72d2d41bf734a0a911f82a963c551b0180016d6c8a22a57
|
7
|
+
data.tar.gz: b3b9cc76cf375490ce8f3bdc438d0b80ea98c5a73537a8cbe09292ffab93ccbfcc0568a8c93cf9427283f897668b6c9481c3b3cbce7e2157f01493c4f1cf9119
|
@@ -1,4 +1,12 @@
|
|
1
1
|
class Hiera
|
2
|
+
class Config
|
3
|
+
class << self
|
4
|
+
def config
|
5
|
+
@config
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
2
10
|
module Backend
|
3
11
|
class Router_backend
|
4
12
|
attr_reader :backends
|
@@ -8,16 +16,31 @@ class Hiera
|
|
8
16
|
require 'yaml'
|
9
17
|
@cache = cache || Filecache.new
|
10
18
|
@backends = {}
|
11
|
-
|
12
|
-
|
13
|
-
backend_config = Config[:router][backend.to_sym] || {}
|
14
|
-
backend_classname = backend_config[:backend_class] || backend
|
19
|
+
Hiera.debug("[hiera-router] I'm here!")
|
20
|
+
Hiera.debug("[hiera-router] My configuration: #{Config[:router].inspect}")
|
15
21
|
|
16
|
-
|
17
|
-
|
22
|
+
if backend_list = Config[:router][:backends]
|
23
|
+
Hiera.debug("[hiera-router] Initializing backends: #{backend_list.keys.join(',')}")
|
24
|
+
backend_list.each do |backend, backend_config|
|
25
|
+
Hiera.debug("[hiera-router] Initializing backend '#{backend}'")
|
26
|
+
backend_classname = backend_config['backend_class'] || backend_config[:backend_class] || backend
|
27
|
+
backend_config_override = backend_config['backend_key'] || backend_config[:backend_key] || backend_classname
|
28
|
+
Hiera.debug("[hiera-router] Backend class for '#{backend}' will be '#{backend_classname}'")
|
29
|
+
|
30
|
+
backend_config = Config[:router].merge({
|
31
|
+
:hierarchy => Config[:hierarchy],
|
32
|
+
:backends => [backend_classname],
|
33
|
+
backend_classname.to_sym => Config[backend_config_override.to_sym] || Config[:router][backend_config_override.to_sym] || {},
|
34
|
+
})
|
35
|
+
@backends[backend.to_sym] = {
|
36
|
+
:class_name => "#{backend_classname.capitalize}_backend",
|
37
|
+
:config => backend_config,
|
38
|
+
}
|
18
39
|
end
|
19
40
|
end
|
20
41
|
|
42
|
+
Hiera.debug("All the backend configs: #{@backends.inspect}")
|
43
|
+
|
21
44
|
Hiera.debug("[hiera-router] hiera router initialized")
|
22
45
|
end
|
23
46
|
def lookup(key, scope, order_override, resolution_type)
|
@@ -119,8 +142,14 @@ class Hiera
|
|
119
142
|
backend_options = options
|
120
143
|
backend_options = backend_options.merge(backend_parameters) if backend_parameters
|
121
144
|
Hiera.debug("[hiera-router] Calling hiera with '#{backend_name}'...")
|
122
|
-
if backend = backends[backend_name]
|
123
|
-
|
145
|
+
if backend = backends[backend_name.to_sym]
|
146
|
+
backend_classname = backend[:class_name]
|
147
|
+
Hiera.debug("[hiera-router] Backend class: #{backend_classname}")
|
148
|
+
config = Config.config
|
149
|
+
Config.load(backend[:config])
|
150
|
+
require "hiera/backend/#{backend_classname.downcase}"
|
151
|
+
result = Hiera::Backend.const_get(backend_classname).new.lookup(backend_options[:key], backend_options[:scope], nil, backend_options[:resolution_type])
|
152
|
+
Config.load(config)
|
124
153
|
else
|
125
154
|
Hiera.warn "Backend '#{backend_name}' was not configured; returning the data as-is."
|
126
155
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Vandeginste
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: |
|
15
15
|
This hiera backend replaces the default yaml backend, but will resend queries to other hiera backends based on the value returned by the yaml files.
|