hiera-router 0.5.1 → 0.5.2

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: 7f19b1cd82ddb117ffb39a9ac96c009a36beae09
4
- data.tar.gz: cf574cf5c9dbf8d9847bcaf2264d3ec0167a0055
3
+ metadata.gz: 8acc6c75c3de393f31c3354966b5dcbf57e1fea5
4
+ data.tar.gz: d0067460a22e3eef04bfc901a909b1f570986a71
5
5
  SHA512:
6
- metadata.gz: c1f166cf511aaff691d838f0729778b46b477c26764302a9bac22cdf200ed579570844edc7c37dd12e22967376627fd39c2723c905ec2bb109a57eed462d495d
7
- data.tar.gz: 1001a914a1fb1c79f84c596a0ea912076646e76a14f3b71cdb73f38a02e2a94f59d329e869d82f96fa5520c59fadba42a8dd719dbc736aed9f37719bd1552ba0
6
+ metadata.gz: 01b9ef533ad0a1b2fc229f2e10b0b0cc7f2ce79f7da8d5f904a304bba36a7d862b6b42fd91ca5446f024e6c7431bf95c6250c9c632bd507196d38c28779dd3c4
7
+ data.tar.gz: 9369764493189bfb644e2c382e247eb55c26c6666b45bb71862d1f3f6da63aaa93ccbc1599446a8323ff9c560b4a03d2c7d08250ee504aa744b088a73e7aed98
@@ -1,5 +1,6 @@
1
1
  require 'hiera/filecache'
2
2
  require 'yaml'
3
+ require 'pry'
3
4
 
4
5
  class Hiera
5
6
  class Config
@@ -62,15 +63,18 @@ class Hiera
62
63
 
63
64
  Hiera.debug("[hiera-router] hiera router initialized")
64
65
  end
65
- def lookup(key, scope, order_override, resolution_type)
66
+ def lookup(lookup_key, scope, order_override, resolution_type)
66
67
  options = {
67
68
  :fqdn => scope['fqdn'],
68
69
  :scope => scope,
69
- :key => key,
70
+ :lookup_key => lookup_key,
70
71
  :order_override => order_override,
71
72
  :resolution_type => resolution_type,
72
73
  }
73
74
 
75
+ key_path = Hiera::Util.split_key(lookup_key)
76
+ key = key_path.shift
77
+
74
78
  cache_key = options.to_s
75
79
  cached_value = @bigcache[cache_key]
76
80
  if cached_value
@@ -78,7 +82,7 @@ class Hiera
78
82
  end
79
83
  answer = nil
80
84
 
81
- Hiera.debug("[hiera-router] Looking up #{key} in yaml backend")
85
+ Hiera.debug("[hiera-router] Looking up #{key} in yaml backend (and then return path #{key_path.inspect})")
82
86
 
83
87
  Backend.datasources(scope, order_override) do |source|
84
88
  yaml_file = Backend.datafile(:router, scope, source, 'yaml') || next
@@ -116,6 +120,11 @@ class Hiera
116
120
  end
117
121
  end
118
122
 
123
+ while e = key_path.shift
124
+ raise Exception, "Hiera subkey '#{e}' not found" unless answer.include?(e)
125
+ answer = answer[e]
126
+ end
127
+
119
128
  @bigcache[cache_key] = {
120
129
  :value => answer,
121
130
  :time => Time.now,
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.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Vandeginste