hiera 1.3.2.rc1 → 1.3.2.rc2
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.
- data/lib/hiera/backend.rb +1 -2
- data/lib/hiera/interpolate.rb +19 -5
- data/lib/hiera/version.rb +1 -1
- data/spec/spec_helper.rb +11 -0
- data/spec/unit/backend_spec.rb +6 -0
- metadata +36 -32
- checksums.yaml +0 -7
data/lib/hiera/backend.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'hiera/util'
|
|
2
|
-
require 'hiera/recursive_guard'
|
|
3
2
|
require 'hiera/interpolate'
|
|
4
3
|
|
|
5
4
|
begin
|
|
@@ -90,7 +89,7 @@ class Hiera
|
|
|
90
89
|
#
|
|
91
90
|
# @api public
|
|
92
91
|
def parse_string(data, scope, extra_data={})
|
|
93
|
-
Hiera::Interpolate.interpolate(data,
|
|
92
|
+
Hiera::Interpolate.interpolate(data, scope, extra_data)
|
|
94
93
|
end
|
|
95
94
|
|
|
96
95
|
# Parses a answer received from data files
|
data/lib/hiera/interpolate.rb
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
require 'hiera/backend'
|
|
2
|
+
require 'hiera/recursive_guard'
|
|
2
3
|
|
|
3
4
|
class Hiera::Interpolate
|
|
4
5
|
class << self
|
|
5
6
|
INTERPOLATION = /%\{([^\}]*)\}/
|
|
6
7
|
METHOD_INTERPOLATION = /%\{(scope|hiera)\(['"]([^"']*)["']\)\}/
|
|
7
8
|
|
|
8
|
-
def interpolate(data,
|
|
9
|
+
def interpolate(data, scope, extra_data)
|
|
10
|
+
if data.is_a?(String)
|
|
11
|
+
# Wrapping do_interpolation in a gsub block ensures we process
|
|
12
|
+
# each interpolation site in isolation using separate recursion guards.
|
|
13
|
+
data.gsub(INTERPOLATION) do |match|
|
|
14
|
+
do_interpolation(match, Hiera::RecursiveGuard.new, scope, extra_data)
|
|
15
|
+
end
|
|
16
|
+
else
|
|
17
|
+
data
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def do_interpolation(data, recurse_guard, scope, extra_data)
|
|
9
22
|
if data.is_a?(String) && (match = data.match(INTERPOLATION))
|
|
10
23
|
interpolation_variable = match[1]
|
|
11
24
|
recurse_guard.check(interpolation_variable) do
|
|
12
25
|
interpolate_method, key = get_interpolation_method_and_key(data)
|
|
13
26
|
interpolated_data = send(interpolate_method, data, key, scope, extra_data)
|
|
14
|
-
|
|
27
|
+
do_interpolation(interpolated_data, recurse_guard, scope, extra_data)
|
|
15
28
|
end
|
|
16
29
|
else
|
|
17
30
|
data
|
|
18
31
|
end
|
|
19
32
|
end
|
|
33
|
+
private :do_interpolation
|
|
20
34
|
|
|
21
35
|
def get_interpolation_method_and_key(data)
|
|
22
36
|
if (match = data.match(METHOD_INTERPOLATION))
|
|
@@ -35,13 +49,13 @@ class Hiera::Interpolate
|
|
|
35
49
|
if value.nil? || value == :undefined
|
|
36
50
|
value = extra_data[key]
|
|
37
51
|
end
|
|
38
|
-
|
|
52
|
+
|
|
53
|
+
value
|
|
39
54
|
end
|
|
40
55
|
private :scope_interpolate
|
|
41
56
|
|
|
42
57
|
def hiera_interpolate(data, key, scope, extra_data)
|
|
43
|
-
|
|
44
|
-
data.sub(METHOD_INTERPOLATION, value)
|
|
58
|
+
Hiera::Backend.lookup(key, nil, scope, nil, :priority)
|
|
45
59
|
end
|
|
46
60
|
private :hiera_interpolate
|
|
47
61
|
end
|
data/lib/hiera/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -8,6 +8,17 @@ require 'tmpdir'
|
|
|
8
8
|
|
|
9
9
|
RSpec.configure do |config|
|
|
10
10
|
config.mock_with :mocha
|
|
11
|
+
|
|
12
|
+
config.after :suite do
|
|
13
|
+
# Log the spec order to a file, but only if the LOG_SPEC_ORDER environment variable is
|
|
14
|
+
# set. This should be enabled on Jenkins runs, as it can be used with Nick L.'s bisect
|
|
15
|
+
# script to help identify and debug order-dependent spec failures.
|
|
16
|
+
if ENV['LOG_SPEC_ORDER']
|
|
17
|
+
File.open("./spec_order.txt", "w") do |logfile|
|
|
18
|
+
config.instance_variable_get(:@files_to_run).each { |f| logfile.puts f }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
11
22
|
end
|
|
12
23
|
|
|
13
24
|
# In ruby 1.8.5 Dir does not have mktmpdir defined, so this monkey patches
|
data/spec/unit/backend_spec.rb
CHANGED
|
@@ -253,6 +253,12 @@ class Hiera
|
|
|
253
253
|
end.to raise_error Hiera::InterpolationLoop, "Detected in [first, second]"
|
|
254
254
|
end
|
|
255
255
|
|
|
256
|
+
it "replaces repeated occurances of the same lookup" do
|
|
257
|
+
scope = {"rspec" => "value"}
|
|
258
|
+
input = "it replaces %{rspec} and %{rspec}"
|
|
259
|
+
Backend.parse_string(input, scope).should == "it replaces value and value"
|
|
260
|
+
end
|
|
261
|
+
|
|
256
262
|
it "replaces hiera interpolations with data looked up in hiera" do
|
|
257
263
|
input = "%{hiera('key1')}"
|
|
258
264
|
scope = {}
|
metadata
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hiera
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.2.
|
|
4
|
+
version: 1.3.2.rc2
|
|
5
|
+
prerelease: 6
|
|
5
6
|
platform: ruby
|
|
6
7
|
authors:
|
|
7
8
|
- Puppet Labs
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date: 2014-02-
|
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: json_pure
|
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
16
18
|
requirements:
|
|
17
|
-
- - '>='
|
|
19
|
+
- - ! '>='
|
|
18
20
|
- !ruby/object:Gem::Version
|
|
19
21
|
version: '0'
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
23
26
|
requirements:
|
|
24
|
-
- - '>='
|
|
27
|
+
- - ! '>='
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: '0'
|
|
27
30
|
description: A pluggable data store for hierarcical data
|
|
@@ -32,69 +35,70 @@ extensions: []
|
|
|
32
35
|
extra_rdoc_files: []
|
|
33
36
|
files:
|
|
34
37
|
- bin/hiera
|
|
35
|
-
- lib/hiera
|
|
36
|
-
- lib/hiera/backend/json_backend.rb
|
|
37
|
-
- lib/hiera/backend/yaml_backend.rb
|
|
38
|
-
- lib/hiera/config.rb
|
|
38
|
+
- lib/hiera.rb
|
|
39
39
|
- lib/hiera/console_logger.rb
|
|
40
|
-
- lib/hiera/
|
|
40
|
+
- lib/hiera/noop_logger.rb
|
|
41
|
+
- lib/hiera/backend/yaml_backend.rb
|
|
42
|
+
- lib/hiera/backend/json_backend.rb
|
|
41
43
|
- lib/hiera/fallback_logger.rb
|
|
42
44
|
- lib/hiera/filecache.rb
|
|
45
|
+
- lib/hiera/version.rb
|
|
46
|
+
- lib/hiera/config.rb
|
|
43
47
|
- lib/hiera/interpolate.rb
|
|
44
|
-
- lib/hiera/noop_logger.rb
|
|
45
|
-
- lib/hiera/puppet_logger.rb
|
|
46
48
|
- lib/hiera/recursive_guard.rb
|
|
47
49
|
- lib/hiera/util.rb
|
|
48
|
-
- lib/hiera/
|
|
49
|
-
- lib/hiera.rb
|
|
50
|
+
- lib/hiera/backend.rb
|
|
51
|
+
- lib/hiera/puppet_logger.rb
|
|
52
|
+
- lib/hiera/error.rb
|
|
50
53
|
- COPYING
|
|
51
54
|
- README.md
|
|
52
55
|
- LICENSE
|
|
53
|
-
- spec/
|
|
54
|
-
- spec/unit/
|
|
56
|
+
- spec/unit/hiera_spec.rb
|
|
57
|
+
- spec/unit/filecache_spec.rb
|
|
55
58
|
- spec/unit/backend/yaml_backend_spec.rb
|
|
59
|
+
- spec/unit/backend/json_backend_spec.rb
|
|
60
|
+
- spec/unit/console_logger_spec.rb
|
|
56
61
|
- spec/unit/backend_spec.rb
|
|
62
|
+
- spec/unit/version_spec.rb
|
|
63
|
+
- spec/unit/puppet_logger_spec.rb
|
|
57
64
|
- spec/unit/config_spec.rb
|
|
58
|
-
- spec/unit/console_logger_spec.rb
|
|
59
65
|
- spec/unit/fallback_logger_spec.rb
|
|
60
|
-
- spec/unit/filecache_spec.rb
|
|
61
|
-
- spec/unit/hiera_spec.rb
|
|
62
|
-
- spec/unit/puppet_logger_spec.rb
|
|
63
66
|
- spec/unit/util_spec.rb
|
|
64
|
-
- spec/
|
|
67
|
+
- spec/spec_helper.rb
|
|
65
68
|
homepage: https://github.com/puppetlabs/hiera
|
|
66
69
|
licenses: []
|
|
67
|
-
metadata: {}
|
|
68
70
|
post_install_message:
|
|
69
71
|
rdoc_options: []
|
|
70
72
|
require_paths:
|
|
71
73
|
- lib
|
|
72
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
|
+
none: false
|
|
73
76
|
requirements:
|
|
74
|
-
- - '>='
|
|
77
|
+
- - ! '>='
|
|
75
78
|
- !ruby/object:Gem::Version
|
|
76
79
|
version: '0'
|
|
77
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
78
82
|
requirements:
|
|
79
|
-
- - '>'
|
|
83
|
+
- - ! '>'
|
|
80
84
|
- !ruby/object:Gem::Version
|
|
81
85
|
version: 1.3.1
|
|
82
86
|
requirements: []
|
|
83
87
|
rubyforge_project:
|
|
84
|
-
rubygems_version:
|
|
88
|
+
rubygems_version: 1.8.23
|
|
85
89
|
signing_key:
|
|
86
|
-
specification_version:
|
|
90
|
+
specification_version: 3
|
|
87
91
|
summary: Light weight hierarchical data store
|
|
88
92
|
test_files:
|
|
89
|
-
- spec/
|
|
90
|
-
- spec/unit/
|
|
93
|
+
- spec/unit/hiera_spec.rb
|
|
94
|
+
- spec/unit/filecache_spec.rb
|
|
91
95
|
- spec/unit/backend/yaml_backend_spec.rb
|
|
96
|
+
- spec/unit/backend/json_backend_spec.rb
|
|
97
|
+
- spec/unit/console_logger_spec.rb
|
|
92
98
|
- spec/unit/backend_spec.rb
|
|
99
|
+
- spec/unit/version_spec.rb
|
|
100
|
+
- spec/unit/puppet_logger_spec.rb
|
|
93
101
|
- spec/unit/config_spec.rb
|
|
94
|
-
- spec/unit/console_logger_spec.rb
|
|
95
102
|
- spec/unit/fallback_logger_spec.rb
|
|
96
|
-
- spec/unit/filecache_spec.rb
|
|
97
|
-
- spec/unit/hiera_spec.rb
|
|
98
|
-
- spec/unit/puppet_logger_spec.rb
|
|
99
103
|
- spec/unit/util_spec.rb
|
|
100
|
-
- spec/
|
|
104
|
+
- spec/spec_helper.rb
|
checksums.yaml
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
SHA1:
|
|
3
|
-
metadata.gz: d09536712a42df9adc396179e989930ecad02f68
|
|
4
|
-
data.tar.gz: a9f6f071ebcd6d4b2f3b51b5356ebdc5539965c8
|
|
5
|
-
SHA512:
|
|
6
|
-
metadata.gz: 75b92dd7914f57c1181531b1b6f9fb107b3d4f60ceeabea05c845b8cea478dff95169e0d2b3338293a0f4de4239e99c8cd82f4008d1cf1296d0250b83deca5a9
|
|
7
|
-
data.tar.gz: 1b33ca1476383bcb4946995b463f98d58f127c34a4f7146d75b4f1995328708487e45e008fc4357bd7dab1c8e69c7bd1ec7f315e8d18cf28393b5c6f5e12961e
|