puppet-ghostbuster 1.2.0 → 1.2.1

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
  SHA256:
3
- metadata.gz: 527ccfac3b00bdcd6f58c17d2825332810f1c954089e596ba1eaf9d0a5015bb6
4
- data.tar.gz: df8b761531f84a9a14527516b508229f35efe27abd1483549f062b6e8efd6eff
3
+ metadata.gz: 833a968929238772dc7ddd1f8fe1df5f7f6619ac35ebd8728dc80a84a81f9797
4
+ data.tar.gz: 66ae42129a1dc62b2db60f26a2579d67317f4c23c20dc2035bcf6b495efb2b14
5
5
  SHA512:
6
- metadata.gz: cbe6f1914075e0f685db3f6252005149c62fd865abb90535823b37a8c9b94780f464583daaf131dce84699853af4b0a7af220c3758cd030bdcb0a167c824b7a4
7
- data.tar.gz: cf926a7365b382b714cc1e32b2ab4cd86cb4bfc4278278374a6ccef61bc4f11b165d6c932d3bc1b86ac5bcb282460240fa0f3f43636cbae24542fcc3dd093f12
6
+ metadata.gz: 65462ffe20fb495d3db8c3742f73dd82e5b6514720d7c821c6b4294d4afeeee3763074bfa401eb6f6d8b1ac7eb81904210a4075b192299f80f94c911bfb424af
7
+ data.tar.gz: 7dc4843877ceee379a1a4e58d046cb21bac6fbf168aad0f036c93d9d1a97b87e4c117c104bf04929e755c3763cdcbbdb882edfae3bbc1f75f65d77a11f47b2b1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.2.1](https://github.com/voxpupuli/puppet-ghostbuster/tree/1.2.1) (2024-02-09)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/puppet-ghostbuster/compare/1.2.0...1.2.1)
8
+
9
+ **Fixed bugs:**
10
+
11
+ - Fix and improve hiera.yaml selection [\#90](https://github.com/voxpupuli/puppet-ghostbuster/pull/90) ([h0tw1r3](https://github.com/h0tw1r3))
12
+
5
13
  ## [1.2.0](https://github.com/voxpupuli/puppet-ghostbuster/tree/1.2.0) (2024-01-29)
6
14
 
7
15
  [Full Changelog](https://github.com/voxpupuli/puppet-ghostbuster/compare/1.1.0...1.2.0)
data/README.md CHANGED
@@ -28,7 +28,7 @@ Environment variables
28
28
 
29
29
  ### HIERA_YAML_PATH
30
30
 
31
- The location of the `hiera.yaml` file. Defaults to `/etc/puppetlabs/code/hiera.yaml`
31
+ The location of the `hiera.yaml` file. Defaults to `./hiera.yaml` or `/etc/puppetlabs/puppet/hiera.yaml` whichever is found first.
32
32
 
33
33
  ### PUPPETDB_URL
34
34
 
@@ -1,3 +1,3 @@
1
1
  class PuppetGhostbuster
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -14,14 +14,23 @@ end
14
14
 
15
15
  PuppetLint.new_check(:ghostbuster_hiera_files) do
16
16
  def hiera
17
- @hiera ||= YAML.load_file(ENV['HIERA_YAML_PATH'] || '/etc/puppetlabs/code/hiera.yaml')
17
+ @hiera ||= if (hiera_file = ENV.fetch('HIERA_YAML_PATH', false))
18
+ YAML.load_file(hiera_file)
19
+ else
20
+ hiera = ['hiera.yaml', '/etc/puppetlabs/puppet/hiera.yaml'].filter_map do |hf|
21
+ YAML.load_file(hf) if hf && File.exist?(hf)
22
+ end
23
+ hiera[0]
24
+ end
18
25
  end
19
26
 
20
27
  def default_datadir
21
- hiera.dig('defaults', 'datadir') || 'hieradata'
28
+ hiera.dig('defaults', 'datadir') || 'data'
22
29
  end
23
30
 
24
31
  def path_in_datadirs?(path)
32
+ return false unless hiera
33
+
25
34
  @data_dirs ||= hiera['hierarchy'].map { |h| (h['datadir'] || default_datadir).chomp('/') }.uniq
26
35
  path.match?(%(./#{Regexp.union(@data_dirs)}/))
27
36
  end
@@ -99,5 +99,24 @@ describe 'ghostbuster_hiera_files' do
99
99
  expect(problems).to contain_warning("Hiera File #{path} seems unused")
100
100
  end
101
101
  end
102
+
103
+ context 'when no hiera.yaml exists' do
104
+ let(:path) { './data/nodes/foo.example.com.yaml' }
105
+
106
+ it {
107
+ allow(File).to receive(:exist?).and_return(false)
108
+ ENV.delete('HIERA_YAML_PATH')
109
+ expect(problems.size).to eq(0)
110
+ }
111
+ end
112
+
113
+ context 'when HIERA_YAML_PATH is set but does not exist' do
114
+ let(:path) { './data/domain/example.com.yaml' }
115
+
116
+ it {
117
+ ENV['HIERA_YAML_PATH'] = './spec/fixtures/j.yaml'
118
+ expect { problems }.to raise_error(Errno::ENOENT)
119
+ }
120
+ end
102
121
  end
103
122
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-ghostbuster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camptocamp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-29 00:00:00.000000000 Z
12
+ date: 2024-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coveralls