puppet-lint-nine-check 0.3.0 → 0.5.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/lib/puppet-lint/plugins/class_alignment/helper.rb +158 -0
- data/lib/puppet-lint/plugins/class_alignment.rb +155 -0
- data/lib/puppet-lint/plugins/class_alignment_params_newline.rb +108 -0
- data/lib/puppet-lint/plugins/no_symbolic_file_modes.rb +51 -0
- data/lib/puppet-lint/plugins/template_file_extension.rb +70 -0
- data/spec/puppet-lint/plugins/class_alignment_equals_spec.rb +477 -0
- data/spec/puppet-lint/plugins/class_alignment_params_newline_spec.rb +257 -0
- data/spec/puppet-lint/plugins/class_alignment_params_spec.rb +321 -0
- data/spec/puppet-lint/plugins/no_symbolic_file_modes_spec.rb +75 -0
- data/spec/puppet-lint/plugins/template_file_extension_spec.rb +188 -0
- data/spec/spec_helper.rb +1 -0
- metadata +28 -7
@@ -0,0 +1,188 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "template_file_extension" do
|
4
|
+
context "when the manifest has no file resources" do
|
5
|
+
let(:code) do
|
6
|
+
<<-TEST_CLASS
|
7
|
+
class no_file_resource {
|
8
|
+
host { 'syslog':
|
9
|
+
ip => '10.10.10.10',
|
10
|
+
}
|
11
|
+
}
|
12
|
+
TEST_CLASS
|
13
|
+
end
|
14
|
+
|
15
|
+
it "does not detect any problems" do
|
16
|
+
expect(problems.size).to eq(0)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when a non-template function is called" do
|
21
|
+
let(:code) do
|
22
|
+
<<-TEST_CLASS
|
23
|
+
class random_function {
|
24
|
+
file { '/tmp/templated':
|
25
|
+
content => random_name('mymodule/single_file.erb'),
|
26
|
+
}
|
27
|
+
}
|
28
|
+
TEST_CLASS
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does not detect any problems" do
|
32
|
+
expect(problems.size).to eq(0)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when the template function is called with one valid file name" do
|
37
|
+
let(:code) do
|
38
|
+
<<-TEST_CLASS
|
39
|
+
class valid_template_filename {
|
40
|
+
file { '/tmp/templated':
|
41
|
+
content => template('mymodule/single_file.erb'),
|
42
|
+
}
|
43
|
+
}
|
44
|
+
TEST_CLASS
|
45
|
+
end
|
46
|
+
|
47
|
+
it "does not detect any problems" do
|
48
|
+
expect(problems.size).to eq(0)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when the epp function is called with one valid file name" do
|
53
|
+
let(:code) do
|
54
|
+
<<-TEST_CLASS
|
55
|
+
class valid_epp_template_filename {
|
56
|
+
file { '/tmp/templated':
|
57
|
+
content => epp('mymodule/single_file.epp'),
|
58
|
+
}
|
59
|
+
}
|
60
|
+
TEST_CLASS
|
61
|
+
end
|
62
|
+
|
63
|
+
it "does not detect any problems" do
|
64
|
+
expect(problems.size).to eq(0)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when the epp function is called with one valid file name and parameters" do
|
69
|
+
let(:code) do
|
70
|
+
<<-TEST_CLASS
|
71
|
+
class valid_epp_template_filename {
|
72
|
+
file { '/tmp/templated':
|
73
|
+
content => epp('mymodule/single_file.epp', {'key' => 'val'}),
|
74
|
+
}
|
75
|
+
}
|
76
|
+
TEST_CLASS
|
77
|
+
end
|
78
|
+
|
79
|
+
it "does not detect any problems" do
|
80
|
+
expect(problems.size).to eq(0)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when a space it present between the template function and opening paren" do
|
85
|
+
let(:code) do
|
86
|
+
<<-TEST_CLASS
|
87
|
+
class space_between_template_and_opening_paren {
|
88
|
+
file { '/tmp/templated':
|
89
|
+
content => template ('mymodule/a_file.erb'),
|
90
|
+
}
|
91
|
+
}
|
92
|
+
TEST_CLASS
|
93
|
+
end
|
94
|
+
|
95
|
+
it "does not detect any problems" do
|
96
|
+
expect(problems.size).to eq(0)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when the template function is called with a single invalid file name" do
|
101
|
+
let(:template_msg) { "all template file names should end with .erb" }
|
102
|
+
let(:code) do
|
103
|
+
<<-TEST_CLASS
|
104
|
+
class multi_templated_file {
|
105
|
+
file { '/tmp/templated':
|
106
|
+
content => template('mymodule/first_file.erb', 'mymodule/second_file.conf'),
|
107
|
+
}
|
108
|
+
}
|
109
|
+
TEST_CLASS
|
110
|
+
end
|
111
|
+
|
112
|
+
it "detects a single problem" do
|
113
|
+
expect(problems.size).to eq(1)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "creates a warning" do
|
117
|
+
expect(problems).to contain_warning(template_msg).on_line(3).in_column(24)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "when the epp function is called with a single invalid file name" do
|
122
|
+
let(:epp_msg) { "all epp file names should end with .epp" }
|
123
|
+
|
124
|
+
let(:code) do
|
125
|
+
<<-TEST_CLASS
|
126
|
+
class epp_multi_templated_file {
|
127
|
+
file { '/tmp/templated':
|
128
|
+
content => epp('mymodule/first_file', {'key' => 'val'}),
|
129
|
+
}
|
130
|
+
}
|
131
|
+
TEST_CLASS
|
132
|
+
end
|
133
|
+
|
134
|
+
it "detects a single problem" do
|
135
|
+
expect(problems.size).to eq(1)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "creates a warning" do
|
139
|
+
expect(problems).to contain_warning(epp_msg).on_line(3).in_column(24)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "when there is a space between the template function and opening paren, and no extension is provided" do
|
144
|
+
let(:template_msg) { "all template file names should end with .erb" }
|
145
|
+
|
146
|
+
let(:code) do
|
147
|
+
<<-TEST_CLASS
|
148
|
+
class space_between_template_and_opening_paren {
|
149
|
+
file { '/tmp/templated':
|
150
|
+
content => template ('mymodule/a_file'),
|
151
|
+
}
|
152
|
+
}
|
153
|
+
TEST_CLASS
|
154
|
+
end
|
155
|
+
|
156
|
+
it "detects a single problem" do
|
157
|
+
expect(problems.size).to eq(1)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "creates a warning" do
|
161
|
+
expect(problems).to contain_warning(template_msg).on_line(3).in_column(24)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
## https://github.com/deanwilson/puppet-lint-template_file_extension-check/issues/48
|
166
|
+
context "when the paramater type is DQPOST not SSTRING and no extension is provided (issue #48)" do
|
167
|
+
let(:template_msg) { "all template file names should end with .erb" }
|
168
|
+
|
169
|
+
let(:code) do
|
170
|
+
<<-TEST_CLASS
|
171
|
+
class space_between_template_and_opening_paren {
|
172
|
+
file { "/etc/${package_name}.conf":
|
173
|
+
ensure => file,
|
174
|
+
content => template("allknowingdns/${package_name}.conf"),
|
175
|
+
}
|
176
|
+
}
|
177
|
+
TEST_CLASS
|
178
|
+
end
|
179
|
+
|
180
|
+
it "detects a single problem" do
|
181
|
+
expect(problems.size).to eq(1)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "creates a warning" do
|
185
|
+
expect(problems).to contain_warning(template_msg).on_line(4).in_column(24)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-nine-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
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:
|
11
|
+
date: 2024-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -108,10 +108,21 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: standardrb
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: " A collection of pupet-lint checks used at Nine.\n"
|
115
126
|
email:
|
116
127
|
- support@nine.ch
|
117
128
|
executables: []
|
@@ -120,14 +131,24 @@ extra_rdoc_files: []
|
|
120
131
|
files:
|
121
132
|
- LICENSE
|
122
133
|
- README.md
|
134
|
+
- lib/puppet-lint/plugins/class_alignment.rb
|
135
|
+
- lib/puppet-lint/plugins/class_alignment/helper.rb
|
136
|
+
- lib/puppet-lint/plugins/class_alignment_params_newline.rb
|
123
137
|
- lib/puppet-lint/plugins/concatenated_template_files.rb
|
124
138
|
- lib/puppet-lint/plugins/explicit_hiera_class_param_lookup.rb
|
125
139
|
- lib/puppet-lint/plugins/nine_legacy_facts.rb
|
140
|
+
- lib/puppet-lint/plugins/no_symbolic_file_modes.rb
|
141
|
+
- lib/puppet-lint/plugins/template_file_extension.rb
|
126
142
|
- lib/puppet-lint/plugins/trailing_newline.rb
|
127
143
|
- lib/puppet-lint/plugins/world_writable_files.rb
|
144
|
+
- spec/puppet-lint/plugins/class_alignment_equals_spec.rb
|
145
|
+
- spec/puppet-lint/plugins/class_alignment_params_newline_spec.rb
|
146
|
+
- spec/puppet-lint/plugins/class_alignment_params_spec.rb
|
128
147
|
- spec/puppet-lint/plugins/concatenated_template_files_spec.rb
|
129
148
|
- spec/puppet-lint/plugins/explicit_hiera_class_param_lookup_spec.rb
|
130
149
|
- spec/puppet-lint/plugins/nine_legacy_facts_spec.rb
|
150
|
+
- spec/puppet-lint/plugins/no_symbolic_file_modes_spec.rb
|
151
|
+
- spec/puppet-lint/plugins/template_file_extension_spec.rb
|
131
152
|
- spec/puppet-lint/plugins/trailing_newline_spec.rb
|
132
153
|
- spec/puppet-lint/plugins/world_writable_files_spec.rb
|
133
154
|
- spec/spec_helper.rb
|
@@ -150,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
171
|
- !ruby/object:Gem::Version
|
151
172
|
version: '0'
|
152
173
|
requirements: []
|
153
|
-
rubygems_version: 3.4.
|
174
|
+
rubygems_version: 3.4.19
|
154
175
|
signing_key:
|
155
176
|
specification_version: 4
|
156
177
|
summary: A puppet-lint plugin for different checks used at Nine.
|