hiera 3.1.2-x64-mingw32 → 3.2.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -316,3 +316,8 @@ Long-term support, including security patches and bug fixes, is available for
316
316
  commercial customers. Please see the following page for more details:
317
317
 
318
318
  [Puppet Enterprise Support Lifecycle](http://puppetlabs.com/misc/puppet-enterprise-lifecycle)
319
+
320
+ ## MAINTAINERS
321
+
322
+ * Thomas Hallgren
323
+ * Henrik Lindberg
data/bin/hiera CHANGED
@@ -28,7 +28,7 @@ require 'pp'
28
28
 
29
29
  options = {
30
30
  :default => nil,
31
- :config => File.join(Hiera::Util.config_dir, 'hiera.yaml'),
31
+ :config => nil,
32
32
  :scope => {},
33
33
  :key => nil,
34
34
  :verbose => false,
data/lib/hiera/util.rb CHANGED
@@ -26,20 +26,24 @@ class Hiera
26
26
 
27
27
  def config_dir
28
28
  if microsoft_windows?
29
- File.join(common_appdata, 'PuppetLabs', 'code')
29
+ File.join(common_appdata, 'PuppetLabs', 'puppet', 'etc')
30
30
  else
31
- '/etc/puppetlabs/code'
31
+ '/etc/puppetlabs/puppet'
32
32
  end
33
33
  end
34
34
 
35
- def var_dir
35
+ def code_dir
36
36
  if microsoft_windows?
37
- File.join(common_appdata, 'PuppetLabs', 'code', 'environments' , '%{environment}' , 'hieradata')
37
+ File.join(common_appdata, 'PuppetLabs', 'code')
38
38
  else
39
- '/etc/puppetlabs/code/environments/%{environment}/hieradata'
39
+ '/etc/puppetlabs/code'
40
40
  end
41
41
  end
42
42
 
43
+ def var_dir
44
+ File.join(code_dir, 'environments' , '%{environment}' , 'hieradata')
45
+ end
46
+
43
47
  def file_alt_separator
44
48
  File::ALT_SEPARATOR
45
49
  end
data/lib/hiera/version.rb CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  class Hiera
10
- VERSION = "3.1.2"
10
+ VERSION = "3.2.0"
11
11
 
12
12
  ##
13
13
  # version is a public API method intended to always provide a fast and
data/lib/hiera.rb CHANGED
@@ -40,9 +40,13 @@ class Hiera
40
40
  # If the config option is a string its assumed to be a filename,
41
41
  # else a hash of what would have been in the YAML config file
42
42
  def initialize(options={})
43
- options[:config] ||= File.join(Util.config_dir, 'hiera.yaml')
44
-
45
- @config = Config.load(options[:config])
43
+ config = options[:config]
44
+ if config.nil?
45
+ # Look in codedir first, then confdir
46
+ config = File.join(Util.code_dir, 'hiera.yaml')
47
+ config = File.join(Util.config_dir, 'hiera.yaml') unless File.exist?(config)
48
+ end
49
+ @config = Config.load(config)
46
50
 
47
51
  Config.load_backends
48
52
  end
@@ -50,22 +50,39 @@ describe "Hiera" do
50
50
  end
51
51
 
52
52
  describe "#initialize" do
53
- it "uses a default config file when none is provided" do
54
- config_file = File.join(Hiera::Util.config_dir, 'hiera.yaml')
55
- Hiera::Config.expects(:load).with(config_file)
56
- Hiera::Config.stubs(:load_backends)
57
- Hiera.new
53
+ before(:each) { Hiera::Config.expects(:load_backends) }
54
+
55
+ context 'when loading the config' do
56
+ let!(:code_config) { File.join(Hiera::Util.code_dir, 'hiera.yaml') }
57
+ let!(:conf_config) { File.join(Hiera::Util.config_dir, 'hiera.yaml') }
58
+ let!(:cli_config) { File.join('/home/bob', 'hiera.yaml') }
59
+
60
+ it 'attempts to load from code_dir first and config_dir second' do
61
+ File.expects(:exist?).with(code_config).returns(false)
62
+ Hiera::Config.expects(:load).with(conf_config)
63
+ Hiera.new
64
+ end
65
+
66
+ it 'does not load from config_dir when file is found in code_dir' do
67
+ File.expects(:exist?).with(code_config).returns(true)
68
+ Hiera::Config.expects(:load).with(code_config)
69
+ Hiera.new
70
+ end
71
+
72
+ it 'makes no attempt to load from code_dir or config_dir when :config is given as an option' do
73
+ File.expects(:exist?).with(code_config).never
74
+ Hiera::Config.expects(:load).with(cli_config)
75
+ Hiera.new(:config => cli_config)
76
+ end
58
77
  end
59
78
 
60
79
  it "passes the supplied config to the config class" do
61
80
  Hiera::Config.expects(:load).with({"test" => "rspec"})
62
- Hiera::Config.stubs(:load_backends)
63
81
  Hiera.new(:config => {"test" => "rspec"})
64
82
  end
65
83
 
66
84
  it "loads all backends on start" do
67
85
  Hiera::Config.stubs(:load)
68
- Hiera::Config.expects(:load_backends)
69
86
  Hiera.new
70
87
  end
71
88
  end
@@ -23,13 +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
- expect(Hiera::Util.config_dir).to eq('/etc/puppetlabs/code')
26
+ expect(Hiera::Util.config_dir).to eq('/etc/puppetlabs/puppet')
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
- expect(Hiera::Util.config_dir).to eq('C:\\ProgramData/PuppetLabs/code')
32
+ expect(Hiera::Util.config_dir).to eq('C:\\ProgramData/PuppetLabs/puppet/etc')
33
+ end
34
+ end
35
+
36
+ describe 'Hiera::Util.code_dir' do
37
+ it 'should return the correct path for posix systems' do
38
+ Hiera::Util.expects(:file_alt_separator).returns(nil)
39
+ expect(Hiera::Util.code_dir).to eq('/etc/puppetlabs/code')
40
+ end
41
+
42
+ it 'should return the correct path for microsoft windows systems' do
43
+ Hiera::Util.expects(:microsoft_windows?).returns(true)
44
+ Hiera::Util.expects(:common_appdata).returns('C:\\ProgramData')
45
+ expect(Hiera::Util.code_dir).to eq('C:\\ProgramData/PuppetLabs/code')
33
46
  end
34
47
  end
35
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.0
5
5
  prerelease:
6
6
  platform: x64-mingw32
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-22 00:00:00.000000000 Z
12
+ date: 2016-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_pure