hiera-http 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/lib/hiera/backend/http_backend.rb +24 -7
- metadata +30 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 63ab1df0ab23f968b79343ec215cffc367e0769d
|
4
|
+
data.tar.gz: 7da4074c7417b661010bb7986b9788dbf7b3fd3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a87f6180b5712df95d7d54a91c11ee50b90a5df488fc0840decd6a59de30d5886afb0ea2182335d6be53bbde17677c369eccdc13abb92ebae4f2d3d286f8081
|
7
|
+
data.tar.gz: ef924a36d8c2b836b656b1be962ff5ec360b2c1543609f08f9560da090776ad3f8a4f7cd72fac1305a1d9da712e5112687e4b482450c003eb47e49f1e3608eb1
|
@@ -15,6 +15,14 @@ class Hiera
|
|
15
15
|
@cache_timeout = @config[:cache_timeout] || 10
|
16
16
|
@cache_clean_interval = @config[:cache_clean_interval] || 3600
|
17
17
|
|
18
|
+
@regex_key_match = nil
|
19
|
+
|
20
|
+
if confine_keys = @config[:confine_to_keys]
|
21
|
+
confine_keys.map! { |r| Regexp.new(r) }
|
22
|
+
@regex_key_match = Regexp.union(confine_keys)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
18
26
|
if @config[:use_ssl]
|
19
27
|
@http.use_ssl = true
|
20
28
|
|
@@ -38,6 +46,15 @@ class Hiera
|
|
38
46
|
end
|
39
47
|
|
40
48
|
def lookup(key, scope, order_override, resolution_type)
|
49
|
+
|
50
|
+
# if confine_to_keys is configured, then only proceed if one of the
|
51
|
+
# regexes matches the lookup key
|
52
|
+
#
|
53
|
+
if @regex_key_match
|
54
|
+
return nil unless key[@regex_key_match] == key
|
55
|
+
end
|
56
|
+
|
57
|
+
|
41
58
|
answer = nil
|
42
59
|
|
43
60
|
paths = @config[:paths].map { |p| Backend.parse_string(p, scope, { 'key' => key }) }
|
@@ -100,22 +117,22 @@ class Hiera
|
|
100
117
|
|
101
118
|
def parse_yaml(answer)
|
102
119
|
require 'yaml'
|
103
|
-
YAML.
|
120
|
+
YAML.load(answer)
|
104
121
|
end
|
105
122
|
|
106
123
|
def http_get_and_parse_with_cache(path)
|
107
|
-
return
|
124
|
+
return http_get_and_parse(path) if @cache_timeout <= 0
|
108
125
|
|
109
126
|
now = Time.now.to_i
|
110
127
|
expired_at = now + @cache_timeout
|
111
128
|
|
112
129
|
# Deleting all stale cache entries can be expensive. Do not do it every time
|
113
|
-
periodically_clean_cache(now
|
130
|
+
periodically_clean_cache(now) unless @cache_clean_interval == 0
|
114
131
|
|
115
132
|
# Just refresh the entry being requested for performance
|
116
|
-
|
133
|
+
if !@cache[path] || @cache[path][:expired_at] < now
|
117
134
|
@cache[path] = {
|
118
|
-
:
|
135
|
+
:expired_at => expired_at,
|
119
136
|
:result => http_get_and_parse(path)
|
120
137
|
}
|
121
138
|
end
|
@@ -150,12 +167,12 @@ class Hiera
|
|
150
167
|
end
|
151
168
|
|
152
169
|
|
153
|
-
def periodically_clean_cache(now
|
170
|
+
def periodically_clean_cache(now)
|
154
171
|
return if now < @clean_cache_at.to_i
|
155
172
|
|
156
173
|
@clean_cache_at = now + @cache_clean_interval
|
157
174
|
@cache.delete_if do |_, entry|
|
158
|
-
entry[:
|
175
|
+
entry[:expired_at] < now
|
159
176
|
end
|
160
177
|
end
|
161
178
|
end
|
metadata
CHANGED
@@ -1,61 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiera-http
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Craig Dunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
requirement:
|
16
|
-
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
19
|
version: 1.1.1
|
20
|
-
version_requirements: *id001
|
21
|
-
prerelease: false
|
22
20
|
type: :runtime
|
23
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.1
|
24
27
|
description: Hiera backend for looking up data over HTTP APIs
|
25
28
|
email: craig@craigdunn.org
|
26
29
|
executables: []
|
27
|
-
|
28
30
|
extensions: []
|
29
|
-
|
30
31
|
extra_rdoc_files: []
|
31
|
-
|
32
|
-
files:
|
32
|
+
files:
|
33
33
|
- lib/hiera/backend/http_backend.rb
|
34
34
|
homepage: http://github.com/crayfishx/hiera-http
|
35
35
|
licenses: []
|
36
|
-
|
37
36
|
metadata: {}
|
38
|
-
|
39
37
|
post_install_message:
|
40
38
|
rdoc_options: []
|
41
|
-
|
42
|
-
require_paths:
|
39
|
+
require_paths:
|
43
40
|
- lib
|
44
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
-
|
47
|
-
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
53
51
|
requirements: []
|
54
|
-
|
55
52
|
rubyforge_project:
|
56
53
|
rubygems_version: 2.0.14
|
57
54
|
signing_key:
|
58
55
|
specification_version: 4
|
59
56
|
summary: HTTP backend for Hiera
|
60
57
|
test_files: []
|
61
|
-
|