puppet-lint-global_definition-check 0.4.0 → 0.4.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2896bfc30e8ea8bb554cf3bb9d287ccd67f77365fb3cc35d505206d34508cc24
|
4
|
+
data.tar.gz: cff254e83cf89d4d6e6bf11bfbb0052d41b85918a7a7760342daa0c5b96ddf76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0294aea977236fe3bfb2f6e34e423f1cc097e51e774691971ffc0db022709d896be7f112b55193d627dea3ef5c9a6ff4fb0ea7e024ce48a515a7b90a1d5bb48e'
|
7
|
+
data.tar.gz: 9b8945fb065a3ab9261155a9fd4aceb184f82f6b97f93af4a3fc62de5fca0a12f0d18d9de47b1e32712c29cc21649be8a741aa8d9baef5e10626974ff706bfc1
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module PuppetLintGlobalDefinionCheck
|
2
2
|
private
|
3
3
|
|
4
|
-
def check_for_global_token(type
|
5
|
-
global_tokens.
|
4
|
+
def check_for_global_token(type)
|
5
|
+
global_tokens.each do |token|
|
6
6
|
next unless token.type == type
|
7
|
-
next unless value.nil? || token.value == value
|
8
7
|
|
9
|
-
message =
|
8
|
+
message = yield(token)
|
9
|
+
next unless message
|
10
10
|
|
11
11
|
notify :error,
|
12
12
|
message: "definition #{message} in global space",
|
@@ -37,7 +37,9 @@ PuppetLint.new_check(:global_resource) do
|
|
37
37
|
|
38
38
|
def check
|
39
39
|
check_for_global_resources
|
40
|
-
check_for_global_token(:NAME
|
40
|
+
check_for_global_token(:NAME) do |token|
|
41
|
+
"#{token.value} #{token.next_code_token.value}" if token.value == "include"
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
45
|
def check_for_global_resources
|
@@ -56,6 +58,8 @@ PuppetLint.new_check(:global_function) do
|
|
56
58
|
include PuppetLintGlobalDefinionCheck
|
57
59
|
|
58
60
|
def check
|
59
|
-
check_for_global_token(:FUNCTION_NAME)
|
61
|
+
check_for_global_token(:FUNCTION_NAME) do |token|
|
62
|
+
"#{token.value} #{token.next_code_token.value}" unless !token.prev_code_token.nil? && token.prev_code_token.type == :FUNCTION
|
63
|
+
end
|
60
64
|
end
|
61
65
|
end
|
@@ -1,53 +1,49 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "
|
4
|
-
context "just a
|
5
|
-
let(:code)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
context "just a define" do
|
13
|
-
let(:code) { "define test ($param = undef) { file { 'file': } }" }
|
14
|
-
|
15
|
-
it "should not detect any problems" do
|
16
|
-
expect(problems).to have(0).problems
|
3
|
+
describe "global_function" do
|
4
|
+
context "just a function" do
|
5
|
+
let(:code) do
|
6
|
+
<<-EOS
|
7
|
+
class test {
|
8
|
+
ensure_packages(['wordpress']);
|
9
|
+
}
|
10
|
+
EOS
|
17
11
|
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "allow node resources" do
|
21
|
-
let(:code) { "node 'test' { file { 'file': } }" }
|
22
12
|
|
23
13
|
it "should not detect any problems" do
|
24
14
|
expect(problems).to have(0).problems
|
25
15
|
end
|
26
16
|
end
|
27
17
|
|
28
|
-
context "global
|
18
|
+
context "global functions" do
|
29
19
|
let(:code) do
|
30
|
-
|
31
|
-
|
20
|
+
<<-EOS
|
21
|
+
class test {
|
22
|
+
ensure_packages(['wordpress']);
|
23
|
+
}
|
32
24
|
|
33
|
-
|
34
|
-
|
25
|
+
ensure_packages(['wordpress']);
|
26
|
+
EOS
|
35
27
|
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "global includes" do
|
39
|
-
let(:code) { "class test { file { 'file': } } \ninclude testclass" }
|
40
28
|
|
41
29
|
it "should detect a problem" do
|
42
30
|
expect(problems).to have(1).problems
|
43
31
|
end
|
44
32
|
end
|
45
33
|
|
46
|
-
context "
|
34
|
+
context "module function definition" do
|
47
35
|
let(:code) do
|
48
36
|
<<-EOS
|
49
|
-
|
50
|
-
|
37
|
+
# @summary function to clean hash of undef and empty values
|
38
|
+
function nine_networkinterfaces::delete_empty_values(
|
39
|
+
Hash $hash,
|
40
|
+
) >> Hash {
|
41
|
+
$hash.filter |$key, $value| {
|
42
|
+
case $value {
|
43
|
+
Collection: { $value =~ NotUndef and !$value.empty }
|
44
|
+
default: { $value =~ NotUndef }
|
45
|
+
}
|
46
|
+
}
|
51
47
|
}
|
52
48
|
EOS
|
53
49
|
end
|
@@ -1,33 +1,59 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "
|
4
|
-
context "just a
|
5
|
-
let(:code)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
EOS
|
3
|
+
describe "global_resource" do
|
4
|
+
context "just a class" do
|
5
|
+
let(:code) { "class test { file { 'file': } }" }
|
6
|
+
|
7
|
+
it "should not detect any problems" do
|
8
|
+
expect(problems).to have(0).problems
|
11
9
|
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "just a define" do
|
13
|
+
let(:code) { "define test ($param = undef) { file { 'file': } }" }
|
12
14
|
|
13
15
|
it "should not detect any problems" do
|
14
16
|
expect(problems).to have(0).problems
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
context "
|
20
|
+
context "allow node resources" do
|
21
|
+
let(:code) { "node 'test' { file { 'file': } }" }
|
22
|
+
|
23
|
+
it "should not detect any problems" do
|
24
|
+
expect(problems).to have(0).problems
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "global file" do
|
19
29
|
let(:code) do
|
20
|
-
|
21
|
-
|
22
|
-
ensure_packages(['wordpress']);
|
23
|
-
}
|
30
|
+
"file { 'file': } define test ($param = undef) { file { 'file': } }"
|
31
|
+
end
|
24
32
|
|
25
|
-
|
26
|
-
|
33
|
+
it "should detect a problem" do
|
34
|
+
expect(problems).to have(1).problems
|
27
35
|
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "global includes" do
|
39
|
+
let(:code) { "class test { file { 'file': } } \ninclude testclass" }
|
28
40
|
|
29
41
|
it "should detect a problem" do
|
30
42
|
expect(problems).to have(1).problems
|
31
43
|
end
|
32
44
|
end
|
45
|
+
|
46
|
+
context "global defaults" do
|
47
|
+
let(:code) do
|
48
|
+
<<-EOS
|
49
|
+
Exec {
|
50
|
+
path => '/usr/bin:/usr/sbin/:/bin:/sbin',
|
51
|
+
}
|
52
|
+
EOS
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not detect any problems" do
|
56
|
+
expect(problems).to have(0).problems
|
57
|
+
end
|
58
|
+
end
|
33
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-global_definition-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nine Internet Solutions AG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|