puppet-ghostbuster 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +4 -1
- data/CHANGELOG.md +21 -0
- data/README.md +5 -0
- data/lib/puppet-ghostbuster/puppetdb.rb +23 -12
- data/lib/puppet-ghostbuster/util.rb +19 -0
- data/lib/puppet-ghostbuster/version.rb +1 -1
- data/lib/puppet-lint/plugins/check_ghostbuster_facts.rb +21 -18
- data/lib/puppet-lint/plugins/check_ghostbuster_files.rb +3 -2
- data/lib/puppet-lint/plugins/check_ghostbuster_functions.rb +4 -3
- data/lib/puppet-lint/plugins/check_ghostbuster_hiera_files.rb +20 -7
- data/lib/puppet-lint/plugins/check_ghostbuster_templates.rb +5 -5
- data/puppet-ghostbuster.gemspec +1 -1
- data/spec/fixtures/hiera.yaml +6 -0
- data/spec/fixtures/modules/foo/lib/facter/asym.rb +8 -0
- data/spec/puppet-lint/plugins/ghostbuster_facts_spec.rb +12 -0
- data/spec/puppet-lint/plugins/ghostbuster_hiera_files_spec.rb +34 -10
- data/spec/spec_helper.rb +1 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 527ccfac3b00bdcd6f58c17d2825332810f1c954089e596ba1eaf9d0a5015bb6
|
4
|
+
data.tar.gz: df8b761531f84a9a14527516b508229f35efe27abd1483549f062b6e8efd6eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbe6f1914075e0f685db3f6252005149c62fd865abb90535823b37a8c9b94780f464583daaf131dce84699853af4b0a7af220c3758cd030bdcb0a167c824b7a4
|
7
|
+
data.tar.gz: cf926a7365b382b714cc1e32b2ab4cd86cb4bfc4278278374a6ccef61bc4f11b165d6c932d3bc1b86ac5bcb282460240fa0f3f43636cbae24542fcc3dd093f12
|
data/.rubocop_todo.yml
CHANGED
@@ -90,6 +90,7 @@ Style/ClassAndModuleChildren:
|
|
90
90
|
Style/ClassVars:
|
91
91
|
Exclude:
|
92
92
|
- 'lib/puppet-ghostbuster/puppetdb.rb'
|
93
|
+
- 'lib/puppet-ghostbuster/util.rb'
|
93
94
|
|
94
95
|
# Offense count: 9
|
95
96
|
# Configuration parameters: AllowedConstants.
|
@@ -98,6 +99,7 @@ Style/Documentation:
|
|
98
99
|
- 'spec/**/*'
|
99
100
|
- 'test/**/*'
|
100
101
|
- 'lib/puppet-ghostbuster/puppetdb.rb'
|
102
|
+
- 'lib/puppet-ghostbuster/util.rb'
|
101
103
|
- 'lib/puppet-lint/plugins/check_ghostbuster_classes.rb'
|
102
104
|
- 'lib/puppet-lint/plugins/check_ghostbuster_defines.rb'
|
103
105
|
- 'lib/puppet-lint/plugins/check_ghostbuster_facts.rb'
|
@@ -114,6 +116,7 @@ Style/Documentation:
|
|
114
116
|
Style/FrozenStringLiteralComment:
|
115
117
|
Exclude:
|
116
118
|
- 'lib/puppet-ghostbuster/puppetdb.rb'
|
119
|
+
- 'lib/puppet-ghostbuster/util.rb'
|
117
120
|
- 'lib/puppet-ghostbuster/version.rb'
|
118
121
|
- 'lib/puppet-lint/plugins/check_ghostbuster_classes.rb'
|
119
122
|
- 'lib/puppet-lint/plugins/check_ghostbuster_defines.rb'
|
@@ -167,4 +170,4 @@ Style/ZeroLengthPredicate:
|
|
167
170
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
168
171
|
# URISchemes: http, https
|
169
172
|
Layout/LineLength:
|
170
|
-
Max:
|
173
|
+
Max: 195
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,27 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [1.2.0](https://github.com/voxpupuli/puppet-ghostbuster/tree/1.2.0) (2024-01-29)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/puppet-ghostbuster/compare/1.1.0...1.2.0)
|
8
|
+
|
9
|
+
**Implemented enhancements:**
|
10
|
+
|
11
|
+
- Support facts by symbol [\#87](https://github.com/voxpupuli/puppet-ghostbuster/pull/87) ([h0tw1r3](https://github.com/h0tw1r3))
|
12
|
+
- support for hiera datadir [\#86](https://github.com/voxpupuli/puppet-ghostbuster/pull/86) ([h0tw1r3](https://github.com/h0tw1r3))
|
13
|
+
- optimize puppetdb query [\#85](https://github.com/voxpupuli/puppet-ghostbuster/pull/85) ([h0tw1r3](https://github.com/h0tw1r3))
|
14
|
+
- optimize search file content [\#84](https://github.com/voxpupuli/puppet-ghostbuster/pull/84) ([h0tw1r3](https://github.com/h0tw1r3))
|
15
|
+
- support puppetdb token authentication [\#73](https://github.com/voxpupuli/puppet-ghostbuster/pull/73) ([h0tw1r3](https://github.com/h0tw1r3))
|
16
|
+
|
17
|
+
**Fixed bugs:**
|
18
|
+
|
19
|
+
- Getting 'ArgumentError: invalid byte sequence in UTF-8' when using ghostbuster\_facts [\#63](https://github.com/voxpupuli/puppet-ghostbuster/issues/63)
|
20
|
+
|
21
|
+
**Merged pull requests:**
|
22
|
+
|
23
|
+
- Update voxpupuli-rubocop requirement from ~\> 2.3.0 to ~\> 2.4.0 [\#82](https://github.com/voxpupuli/puppet-ghostbuster/pull/82) ([dependabot[bot]](https://github.com/apps/dependabot))
|
24
|
+
- Update voxpupuli-rubocop requirement from ~\> 2.2.0 to ~\> 2.3.0 [\#81](https://github.com/voxpupuli/puppet-ghostbuster/pull/81) ([dependabot[bot]](https://github.com/apps/dependabot))
|
25
|
+
|
5
26
|
## [1.1.0](https://github.com/voxpupuli/puppet-ghostbuster/tree/1.1.0) (2024-01-08)
|
6
27
|
|
7
28
|
[Full Changelog](https://github.com/voxpupuli/puppet-ghostbuster/compare/1.0.0...1.1.0)
|
data/README.md
CHANGED
@@ -46,6 +46,11 @@ An SSL certificate signed by your site’s Puppet CA
|
|
46
46
|
|
47
47
|
The private key for that certificate
|
48
48
|
|
49
|
+
### PE_TOKEN
|
50
|
+
|
51
|
+
If set, PE token authentication will be used instead of certificate authentication.
|
52
|
+
Value may be a token _or_ path to a file containing a token.
|
53
|
+
|
49
54
|
Plugins
|
50
55
|
-------
|
51
56
|
|
@@ -13,14 +13,25 @@ class PuppetGhostbuster
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.client
|
16
|
-
@@client ||=
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
@@client ||= begin
|
17
|
+
options = {
|
18
|
+
server: ENV['PUPPETDB_URL'] || @@puppetdb,
|
19
|
+
}
|
20
|
+
|
21
|
+
if ENV['PE_TOKEN']
|
22
|
+
token_file = File.expand_path(ENV['PE_TOKEN'])
|
23
|
+
options[:token] = File.exist?(token_file) ? File.read(token_file) : ENV.fetch('PE_TOKEN')
|
24
|
+
options[:cacert] = ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert]
|
25
|
+
else
|
26
|
+
options[:pem] = {
|
27
|
+
'key' => ENV['PUPPETDB_KEY_FILE'] || Puppet[:hostprivkey],
|
28
|
+
'cert' => ENV['PUPPETDB_CERT_FILE'] || Puppet[:hostcert],
|
29
|
+
'ca_file' => ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert],
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
::PuppetDB::Client.new(options, 4)
|
34
|
+
end
|
24
35
|
end
|
25
36
|
|
26
37
|
def client
|
@@ -29,9 +40,9 @@ class PuppetGhostbuster
|
|
29
40
|
|
30
41
|
def self.classes
|
31
42
|
@@classes ||= client.request('',
|
32
|
-
'resources[title] { type = "Class" and nodes { deactivated is null } }').data.map do |r|
|
43
|
+
'resources[title] { type = "Class" and nodes { deactivated is null } group by title }').data.map do |r|
|
33
44
|
r['title']
|
34
|
-
end
|
45
|
+
end
|
35
46
|
end
|
36
47
|
|
37
48
|
def classes
|
@@ -39,9 +50,9 @@ class PuppetGhostbuster
|
|
39
50
|
end
|
40
51
|
|
41
52
|
def self.resources
|
42
|
-
@@resources ||= client.request('', 'resources[type] { nodes { deactivated is null } }').data.map do |r|
|
53
|
+
@@resources ||= client.request('', 'resources[type] { nodes { deactivated is null } group by type }').data.map do |r|
|
43
54
|
r['type']
|
44
|
-
end
|
55
|
+
end
|
45
56
|
end
|
46
57
|
|
47
58
|
def resources
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class PuppetGhostbuster
|
2
|
+
class Util
|
3
|
+
class << self
|
4
|
+
def search_file(name, search)
|
5
|
+
return search_file_regexp(name, search) if search.is_a?(Regexp)
|
6
|
+
|
7
|
+
File.foreach(name) do |line|
|
8
|
+
return true if line.include?(search)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def search_file_regexp(name, search)
|
13
|
+
File.foreach(name) do |line|
|
14
|
+
return true if line.match?(search)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet-ghostbuster/util'
|
2
|
+
|
1
3
|
class PuppetLint::Checks
|
2
4
|
def load_data(path, content)
|
3
5
|
lexer = PuppetLint::Lexer.new
|
@@ -25,29 +27,30 @@ PuppetLint.new_check(:ghostbuster_facts) do
|
|
25
27
|
m = path.match(%r{.*/([^/]+)/lib/facter/(.+)$})
|
26
28
|
return if m.nil?
|
27
29
|
|
28
|
-
File.
|
29
|
-
|
30
|
+
File.foreach(path) do |line|
|
31
|
+
if line =~ /Facter.add\(["':](?<fact>[^"'\)]+)["']?\)/
|
32
|
+
fact_name = Regexp.last_match(:fact)
|
30
33
|
|
31
|
-
|
34
|
+
found = false
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
36
|
+
manifests.each do |manifest|
|
37
|
+
found = true unless PuppetGhostbuster::Util.search_file(manifest, /(\$\{?::#{fact_name}\}?|@#{fact_name})/).nil?
|
38
|
+
break if found
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
templates.each do |template|
|
42
|
+
found = true unless PuppetGhostbuster::Util.search_file(template, /@#{fact_name}/).nil?
|
43
|
+
break if found
|
44
|
+
end
|
43
45
|
|
44
|
-
|
46
|
+
next if found
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
notify :warning, {
|
49
|
+
message: "Fact #{fact_name} seems unused",
|
50
|
+
line: 1,
|
51
|
+
column: 1,
|
52
|
+
}
|
53
|
+
end
|
51
54
|
end
|
52
55
|
end
|
53
56
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'puppet-ghostbuster/puppetdb'
|
2
|
+
require 'puppet-ghostbuster/util'
|
2
3
|
|
3
4
|
class PuppetLint::Checks
|
4
5
|
def load_data(path, content)
|
@@ -42,9 +43,9 @@ PuppetLint.new_check(:ghostbuster_files) do
|
|
42
43
|
end
|
43
44
|
|
44
45
|
manifests.each do |manifest|
|
45
|
-
return if
|
46
|
+
return if PuppetGhostbuster::Util.search_file(manifest, %r{["']#{module_name}/#{file_name}["']})
|
46
47
|
|
47
|
-
if (match = manifest.match(%r{.*/([^/]+)/manifests/.+$})) && (match.captures[0] == module_name) &&
|
48
|
+
if (match = manifest.match(%r{.*/([^/]+)/manifests/.+$})) && (match.captures[0] == module_name) && PuppetGhostbuster::Util.search_file(manifest, %r{["']\$\{module_name\}/#{file_name}["']})
|
48
49
|
return
|
49
50
|
end
|
50
51
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet-ghostbuster/util'
|
2
|
+
|
1
3
|
class PuppetLint::Checks
|
2
4
|
def load_data(path, content)
|
3
5
|
lexer = PuppetLint::Lexer.new
|
@@ -28,12 +30,11 @@ PuppetLint.new_check(:ghostbuster_functions) do
|
|
28
30
|
function_name = m.captures[0]
|
29
31
|
|
30
32
|
manifests.each do |manifest|
|
31
|
-
return if
|
33
|
+
return if PuppetGhostbuster::Util.search_file(manifest, "#{function_name}(")
|
32
34
|
end
|
33
35
|
|
34
36
|
templates.each do |template|
|
35
|
-
return if
|
36
|
-
return if File.readlines(template).grep(/Puppet::Parser::Functions.function\(:#{function_name}/).size > 0
|
37
|
+
return if PuppetGhostbuster::Util.search_file(template, /(Puppet::Parser::Functions\.function\(:|scope\.function_)#{function_name}/)
|
37
38
|
end
|
38
39
|
|
39
40
|
notify :warning, {
|
@@ -13,13 +13,26 @@ class PuppetLint::Checks
|
|
13
13
|
end
|
14
14
|
|
15
15
|
PuppetLint.new_check(:ghostbuster_hiera_files) do
|
16
|
+
def hiera
|
17
|
+
@hiera ||= YAML.load_file(ENV['HIERA_YAML_PATH'] || '/etc/puppetlabs/code/hiera.yaml')
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_datadir
|
21
|
+
hiera.dig('defaults', 'datadir') || 'hieradata'
|
22
|
+
end
|
23
|
+
|
24
|
+
def path_in_datadirs?(path)
|
25
|
+
@data_dirs ||= hiera['hierarchy'].map { |h| (h['datadir'] || default_datadir).chomp('/') }.uniq
|
26
|
+
path.match?(%(./#{Regexp.union(@data_dirs)}/))
|
27
|
+
end
|
28
|
+
|
16
29
|
def regexprs
|
17
|
-
hiera_yaml_file = ENV['HIERA_YAML_PATH'] || '/etc/puppetlabs/code/hiera.yaml'
|
18
|
-
hiera = YAML.load_file(hiera_yaml_file)
|
19
30
|
regs = {}
|
20
31
|
hiera['hierarchy'].each do |hierarchy|
|
32
|
+
path_datadir = Regexp.escape((hierarchy['datadir'] || default_datadir).chomp('/'))
|
21
33
|
([*hierarchy['path']] + [*hierarchy['paths']]).each do |level|
|
22
|
-
|
34
|
+
level = File.join(path_datadir, level)
|
35
|
+
regex = Regexp.new(level.gsub(/%\{(::)?(trusted|server_facts|facts)\.[^\}]+\}/, '(.+)').gsub(/%\{[^\}]+\}/, '.+'))
|
23
36
|
facts = level.match(regex).captures.map { |f| f[/%{(::)?(trusted|server_facts|facts)\.(.+)}/, 3] }
|
24
37
|
regs[regex] = facts
|
25
38
|
end
|
@@ -28,14 +41,14 @@ PuppetLint.new_check(:ghostbuster_hiera_files) do
|
|
28
41
|
end
|
29
42
|
|
30
43
|
def check
|
31
|
-
return
|
44
|
+
return unless path_in_datadirs? path
|
32
45
|
|
33
46
|
puppetdb = PuppetGhostbuster::PuppetDB.new
|
34
|
-
_path = path.gsub('./hieradata/', '')
|
35
47
|
|
36
48
|
regexprs.each do |k, v|
|
37
|
-
m =
|
49
|
+
m = path.match(k)
|
38
50
|
next if m.nil?
|
51
|
+
|
39
52
|
return if m.captures.size == 0
|
40
53
|
|
41
54
|
if m.captures.size > 1
|
@@ -68,7 +81,7 @@ PuppetLint.new_check(:ghostbuster_hiera_files) do
|
|
68
81
|
end
|
69
82
|
|
70
83
|
notify :warning, {
|
71
|
-
message: "Hiera File #{
|
84
|
+
message: "Hiera File #{path} seems unused",
|
72
85
|
line: 1,
|
73
86
|
column: 1,
|
74
87
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet-ghostbuster/util'
|
2
|
+
|
1
3
|
class PuppetLint::Checks
|
2
4
|
def load_data(path, content)
|
3
5
|
lexer = PuppetLint::Lexer.new
|
@@ -28,19 +30,17 @@ PuppetLint.new_check(:ghostbuster_templates) do
|
|
28
30
|
module_name, template_name = m.captures
|
29
31
|
|
30
32
|
manifests.each do |manifest|
|
31
|
-
return if
|
33
|
+
return if PuppetGhostbuster::Util.search_file(manifest, %r{["']#{module_name}/#{template_name}["']})
|
32
34
|
|
33
35
|
next unless match = manifest.match(%r{.*/([^/]+)/manifests/.+$})
|
34
36
|
|
35
|
-
if match.captures[0] == module_name &&
|
37
|
+
if match.captures[0] == module_name && PuppetGhostbuster::Util.search_file(manifest, %r{["']\$\{module_name\}/#{template_name}["']})
|
36
38
|
return
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
templates.each do |template|
|
41
|
-
if
|
42
|
-
return
|
43
|
-
end
|
43
|
+
return if PuppetGhostbuster::Util.search_file(template, "scope.function_template(['#{module_name}/#{template_name}'])")
|
44
44
|
end
|
45
45
|
|
46
46
|
notify :warning, {
|
data/puppet-ghostbuster.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
24
24
|
s.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
|
25
25
|
s.add_development_dependency 'rspec-its', '~> 1.0'
|
26
|
-
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.
|
26
|
+
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.4.0'
|
27
27
|
s.add_runtime_dependency 'json', '>= 2.0', '< 3.0'
|
28
28
|
s.add_runtime_dependency 'puppet', '>= 6.0', '< 9.0'
|
29
29
|
s.add_dependency 'puppet-lint', '>= 1.0', '< 5.0'
|
data/spec/fixtures/hiera.yaml
CHANGED
@@ -53,5 +53,17 @@ describe 'ghostbuster_facts' do
|
|
53
53
|
expect(problems.size).to eq(0)
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
context 'when added fact is a symbol and unused' do
|
58
|
+
let(:path) { './spec/fixtures/modules/foo/lib/facter/asym.rb' }
|
59
|
+
|
60
|
+
it 'detects one problem' do
|
61
|
+
expect(problems.size).to eq(1)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'creates a warning' do
|
65
|
+
expect(problems).to contain_warning('Fact asym seems unused')
|
66
|
+
end
|
67
|
+
end
|
56
68
|
end
|
57
69
|
end
|
@@ -9,19 +9,19 @@ describe 'ghostbuster_hiera_files' do
|
|
9
9
|
|
10
10
|
context 'with fix disabled' do
|
11
11
|
context 'when a certname file is NOT used' do
|
12
|
-
let(:path) { './
|
12
|
+
let(:path) { './data/nodes/foo.example.com.yaml' }
|
13
13
|
|
14
14
|
it 'detects one problem' do
|
15
15
|
expect(problems.size).to eq(1)
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'creates a warning' do
|
19
|
-
expect(problems).to contain_warning(
|
19
|
+
expect(problems).to contain_warning("Hiera File #{path} seems unused")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'when a certname file is used' do
|
24
|
-
let(:path) { './
|
24
|
+
let(:path) { './data/nodes/bar.example.com.yaml' }
|
25
25
|
|
26
26
|
it 'does not detect any problem' do
|
27
27
|
expect(problems.size).to eq(0)
|
@@ -29,19 +29,19 @@ describe 'ghostbuster_hiera_files' do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'when an environment file is NOT used' do
|
32
|
-
let(:path) { './
|
32
|
+
let(:path) { './data/environment/foo.yaml' }
|
33
33
|
|
34
34
|
it 'detects one problem' do
|
35
35
|
expect(problems.size).to eq(1)
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'creates a warning' do
|
39
|
-
expect(problems).to contain_warning(
|
39
|
+
expect(problems).to contain_warning("Hiera File #{path} seems unused")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'when an environment file is used' do
|
44
|
-
let(:path) { './
|
44
|
+
let(:path) { './data/environment/production.yaml' }
|
45
45
|
|
46
46
|
it 'does not detect any problem' do
|
47
47
|
expect(problems.size).to eq(0)
|
@@ -49,31 +49,55 @@ describe 'ghostbuster_hiera_files' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'when an fact is NOT used' do
|
52
|
-
let(:path) { './
|
52
|
+
let(:path) { './data/virtual/false.yaml' }
|
53
53
|
|
54
54
|
it 'detects one problem' do
|
55
55
|
expect(problems.size).to eq(1)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'creates a warning' do
|
59
|
-
expect(problems).to contain_warning(
|
59
|
+
expect(problems).to contain_warning("Hiera File #{path} seems unused")
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'when an fact file is used' do
|
64
|
-
let(:path) { './
|
64
|
+
let(:path) { './data/virtual/true.yaml' }
|
65
65
|
|
66
66
|
it 'does not detect any problem' do
|
67
67
|
expect(problems.size).to eq(0)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
context 'when an fact file is used with wrong extension' do
|
72
|
+
let(:path) { './data/virtual/true.eyaml' }
|
73
|
+
|
74
|
+
it 'detects one problem' do
|
75
|
+
expect(problems.size).to eq(1)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'creates a warning' do
|
79
|
+
expect(problems).to contain_warning("Hiera File #{path} seems unused")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
71
83
|
context 'when using a variable in hierarchy' do
|
72
|
-
let(:path) { './
|
84
|
+
let(:path) { './data/domain/example.com.yaml' }
|
73
85
|
|
74
86
|
it 'does not detect any problem' do
|
75
87
|
expect(problems.size).to eq(0)
|
76
88
|
end
|
77
89
|
end
|
90
|
+
|
91
|
+
context 'when hierarchy datadir is NOT default and NOT used' do
|
92
|
+
let(:path) { './private/nodes/privates.example.com.eyaml' }
|
93
|
+
|
94
|
+
it 'detects one problem' do
|
95
|
+
expect(problems.size).to eq(1)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'creates a warning' do
|
99
|
+
expect(problems).to contain_warning("Hiera File #{path} seems unused")
|
100
|
+
end
|
101
|
+
end
|
78
102
|
end
|
79
103
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -21,6 +21,7 @@ class PuppetDB::Client
|
|
21
21
|
endpoint_cols = query.split('{').first
|
22
22
|
endpoint = endpoint_cols.split(/[\s\[]/).first
|
23
23
|
query.sub!(/^#{Regexp.quote(endpoint_cols)}\{\s*/, '')
|
24
|
+
query.sub!(/(group\s+by\s+(type|title))/, '')
|
24
25
|
query.sub!(/\s*}\s*/, '')
|
25
26
|
query.sub!(/(and\s+)?nodes\s*\{\s*deactivated\s+is\s+null\s*\}/, '')
|
26
27
|
|
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.
|
4
|
+
version: 1.2.0
|
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-
|
12
|
+
date: 2024-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: coveralls
|
@@ -119,14 +119,14 @@ dependencies:
|
|
119
119
|
requirements:
|
120
120
|
- - "~>"
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 2.
|
122
|
+
version: 2.4.0
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
127
|
- - "~>"
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: 2.
|
129
|
+
version: 2.4.0
|
130
130
|
- !ruby/object:Gem::Dependency
|
131
131
|
name: json
|
132
132
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- README.md
|
226
226
|
- Rakefile
|
227
227
|
- lib/puppet-ghostbuster/puppetdb.rb
|
228
|
+
- lib/puppet-ghostbuster/util.rb
|
228
229
|
- lib/puppet-ghostbuster/version.rb
|
229
230
|
- lib/puppet-lint/plugins/check_ghostbuster_classes.rb
|
230
231
|
- lib/puppet-lint/plugins/check_ghostbuster_defines.rb
|
@@ -236,6 +237,7 @@ files:
|
|
236
237
|
- lib/puppet-lint/plugins/check_ghostbuster_types.rb
|
237
238
|
- puppet-ghostbuster.gemspec
|
238
239
|
- spec/fixtures/hiera.yaml
|
240
|
+
- spec/fixtures/modules/foo/lib/facter/asym.rb
|
239
241
|
- spec/fixtures/modules/foo/lib/facter/bar.rb
|
240
242
|
- spec/fixtures/modules/foo/lib/facter/baz.rb
|
241
243
|
- spec/fixtures/modules/foo/lib/facter/foo.rb
|