hiera 1.3.4 → 2.0.0
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 +4 -4
- data/LICENSE +1 -1
- data/README.md +47 -10
- data/bin/hiera +48 -31
- data/lib/hiera.rb +55 -3
- data/lib/hiera/backend.rb +124 -37
- data/lib/hiera/backend/json_backend.rb +9 -7
- data/lib/hiera/backend/yaml_backend.rb +9 -7
- data/lib/hiera/config.rb +1 -3
- data/lib/hiera/interpolate.rb +52 -16
- data/lib/hiera/util.rb +5 -5
- data/lib/hiera/version.rb +1 -1
- data/spec/spec_helper.rb +12 -0
- data/spec/unit/backend/json_backend_spec.rb +9 -9
- data/spec/unit/backend/yaml_backend_spec.rb +20 -15
- data/spec/unit/backend_spec.rb +186 -32
- data/spec/unit/config_spec.rb +15 -0
- data/spec/unit/fixtures/interpolate/config/hiera.yaml +6 -0
- data/spec/unit/fixtures/interpolate/data/niltest.yaml +2 -0
- data/spec/unit/fixtures/interpolate/data/recursive.yaml +3 -0
- data/spec/unit/fixtures/override/config/hiera.yaml +5 -0
- data/spec/unit/fixtures/override/data/alternate.yaml +1 -0
- data/spec/unit/fixtures/override/data/common.yaml +2 -0
- data/spec/unit/interpolate_spec.rb +36 -0
- data/spec/unit/util_spec.rb +4 -4
- metadata +17 -3
data/spec/unit/config_spec.rb
CHANGED
@@ -72,6 +72,21 @@ class Hiera
|
|
72
72
|
Config.load('/dev/null')
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
describe "if deep_merge can't be loaded" do
|
77
|
+
let(:error_message) { "Must have 'deep_merge' gem installed for the configured merge_behavior." }
|
78
|
+
before(:each) do
|
79
|
+
Config.expects(:require).with("deep_merge").raises(LoadError, "unable to load")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should error if merge_behavior is 'deep'" do
|
83
|
+
expect { Config.load(:merge_behavior => :deep) }.to raise_error(Hiera::Error, error_message)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should error if merge_behavior is 'deeper'" do
|
87
|
+
expect { Config.load(:merge_behavior => :deeper) }.to raise_error(Hiera::Error, error_message)
|
88
|
+
end
|
89
|
+
end
|
75
90
|
end
|
76
91
|
|
77
92
|
describe "#load_backends" do
|
@@ -0,0 +1 @@
|
|
1
|
+
bar: 'alternate'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hiera/util'
|
3
|
+
|
4
|
+
describe "Hiera" do
|
5
|
+
context "when doing interpolation" do
|
6
|
+
let(:fixtures) { File.join(HieraSpec::FIXTURE_DIR, 'interpolate') }
|
7
|
+
|
8
|
+
it 'should prevent endless recursion' do
|
9
|
+
Hiera::Util.expects(:var_dir).at_least_once.returns(File.join(fixtures, 'data'))
|
10
|
+
hiera = Hiera.new(:config => File.join(fixtures, 'config', 'hiera.yaml'))
|
11
|
+
expect do
|
12
|
+
hiera.lookup('foo', nil, {})
|
13
|
+
end.to raise_error Hiera::InterpolationLoop, 'Detected in [hiera("bar"), hiera("foo")]'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when not finding value for interpolated key" do
|
18
|
+
let(:fixtures) { File.join(HieraSpec::FIXTURE_DIR, 'interpolate') }
|
19
|
+
|
20
|
+
it 'should resolve the interpolation to an empty string' do
|
21
|
+
Hiera::Util.expects(:var_dir).at_least_once.returns(File.join(fixtures, 'data'))
|
22
|
+
hiera = Hiera.new(:config => File.join(fixtures, 'config', 'hiera.yaml'))
|
23
|
+
expect(hiera.lookup('niltest', nil, {})).to eq('Missing key ##. Key with nil ##')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when doing interpolation with override" do
|
28
|
+
let(:fixtures) { File.join(HieraSpec::FIXTURE_DIR, 'override') }
|
29
|
+
|
30
|
+
it 'should resolve interpolation using the override' do
|
31
|
+
Hiera::Util.expects(:var_dir).at_least_once.returns(File.join(fixtures, 'data'))
|
32
|
+
hiera = Hiera.new(:config => File.join(fixtures, 'config', 'hiera.yaml'))
|
33
|
+
expect(hiera.lookup('foo', nil, {}, 'alternate')).to eq('alternate')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/unit/util_spec.rb
CHANGED
@@ -23,26 +23,26 @@ describe Hiera::Util do
|
|
23
23
|
describe 'Hiera::Util.config_dir' do
|
24
24
|
it 'should return the correct path for posix systems' do
|
25
25
|
Hiera::Util.expects(:file_alt_separator).returns(nil)
|
26
|
-
Hiera::Util.config_dir.should == '/etc'
|
26
|
+
Hiera::Util.config_dir.should == '/etc/puppetlabs/code'
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should return the correct path for microsoft windows systems' do
|
30
30
|
Hiera::Util.expects(:microsoft_windows?).returns(true)
|
31
31
|
Hiera::Util.expects(:common_appdata).returns('C:\\ProgramData')
|
32
|
-
Hiera::Util.config_dir.should == 'C:\\ProgramData/PuppetLabs/
|
32
|
+
Hiera::Util.config_dir.should == 'C:\\ProgramData/PuppetLabs/code'
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe 'Hiera::Util.var_dir' do
|
37
37
|
it 'should return the correct path for posix systems' do
|
38
38
|
Hiera::Util.expects(:file_alt_separator).returns(nil)
|
39
|
-
Hiera::Util.var_dir.should == '/
|
39
|
+
Hiera::Util.var_dir.should == '/etc/puppetlabs/code/hieradata'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should return the correct path for microsoft windows systems' do
|
43
43
|
Hiera::Util.expects(:microsoft_windows?).returns(true)
|
44
44
|
Hiera::Util.expects(:common_appdata).returns('C:\\ProgramData')
|
45
|
-
Hiera::Util.var_dir.should == 'C:\\ProgramData/PuppetLabs/
|
45
|
+
Hiera::Util.var_dir.should == 'C:\\ProgramData/PuppetLabs/code/hieradata'
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_pure
|
@@ -58,7 +58,14 @@ files:
|
|
58
58
|
- spec/unit/console_logger_spec.rb
|
59
59
|
- spec/unit/fallback_logger_spec.rb
|
60
60
|
- spec/unit/filecache_spec.rb
|
61
|
+
- spec/unit/fixtures/interpolate/config/hiera.yaml
|
62
|
+
- spec/unit/fixtures/interpolate/data/niltest.yaml
|
63
|
+
- spec/unit/fixtures/interpolate/data/recursive.yaml
|
64
|
+
- spec/unit/fixtures/override/config/hiera.yaml
|
65
|
+
- spec/unit/fixtures/override/data/alternate.yaml
|
66
|
+
- spec/unit/fixtures/override/data/common.yaml
|
61
67
|
- spec/unit/hiera_spec.rb
|
68
|
+
- spec/unit/interpolate_spec.rb
|
62
69
|
- spec/unit/puppet_logger_spec.rb
|
63
70
|
- spec/unit/util_spec.rb
|
64
71
|
- spec/unit/version_spec.rb
|
@@ -81,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
88
|
version: '0'
|
82
89
|
requirements: []
|
83
90
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.0.
|
91
|
+
rubygems_version: 2.0.14
|
85
92
|
signing_key:
|
86
93
|
specification_version: 4
|
87
94
|
summary: Light weight hierarchical data store
|
@@ -94,7 +101,14 @@ test_files:
|
|
94
101
|
- spec/unit/console_logger_spec.rb
|
95
102
|
- spec/unit/fallback_logger_spec.rb
|
96
103
|
- spec/unit/filecache_spec.rb
|
104
|
+
- spec/unit/fixtures/interpolate/config/hiera.yaml
|
105
|
+
- spec/unit/fixtures/interpolate/data/niltest.yaml
|
106
|
+
- spec/unit/fixtures/interpolate/data/recursive.yaml
|
107
|
+
- spec/unit/fixtures/override/config/hiera.yaml
|
108
|
+
- spec/unit/fixtures/override/data/alternate.yaml
|
109
|
+
- spec/unit/fixtures/override/data/common.yaml
|
97
110
|
- spec/unit/hiera_spec.rb
|
111
|
+
- spec/unit/interpolate_spec.rb
|
98
112
|
- spec/unit/puppet_logger_spec.rb
|
99
113
|
- spec/unit/util_spec.rb
|
100
114
|
- spec/unit/version_spec.rb
|