puppet-lint-fileserver-check 1.0.0 → 1.1.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 645b0edd4d64a696a598dd3253adb1d8cc160f31
|
|
4
|
+
data.tar.gz: bb3a09d4048b9fae10d55c5da7e7072176e14490
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f6063629cb0b4964bbee81779f501381a462c82eb17c08083a0f86bd264a33e982297f8938f637645c11aa6d5edf058f290787e81a9e984adb0c6a95d5cb9b5
|
|
7
|
+
data.tar.gz: c8467b9f3a604dafe999277c88fb4655577c6576b315e3e4d76269165f38c6ca03acf54481840be0338738b8c71cc43c626e956d260db908e6bbd53999ba6471
|
|
@@ -20,6 +20,28 @@ PuppetLint.new_check(:fileserver) do
|
|
|
20
20
|
problem[:token].prev_code_token.prev_code_token.value = 'content'
|
|
21
21
|
problem[:token].value.sub!(%r{^puppet:///modules/(.*)}, "file('\\1')")
|
|
22
22
|
problem[:token].type = :NAME
|
|
23
|
+
elsif problem[:token].type == :DQPRE
|
|
24
|
+
problem[:token].prev_code_token.prev_code_token.value = 'content'
|
|
25
|
+
file = PuppetLint::Lexer::Token.new(
|
|
26
|
+
:NAME, 'file',
|
|
27
|
+
problem[:token].line, problem[:token].column+1
|
|
28
|
+
)
|
|
29
|
+
lparen = PuppetLint::Lexer::Token.new(
|
|
30
|
+
:LPAREN, '(',
|
|
31
|
+
problem[:token].line, problem[:token].column+1
|
|
32
|
+
)
|
|
33
|
+
rparen = PuppetLint::Lexer::Token.new(
|
|
34
|
+
:RPAREN, ')',
|
|
35
|
+
problem[:token].line, problem[:token].column+1
|
|
36
|
+
)
|
|
37
|
+
tokens.insert(tokens.index(problem[:token]), file)
|
|
38
|
+
tokens.insert(tokens.index(problem[:token]), lparen)
|
|
39
|
+
problem[:token].value.sub!(%r{^puppet:///modules/}, '')
|
|
40
|
+
t = problem[:token].next_code_token
|
|
41
|
+
while t.type != :DQPOST
|
|
42
|
+
t = t.next_code_token
|
|
43
|
+
end
|
|
44
|
+
tokens.insert(tokens.index(t)+1, rparen)
|
|
23
45
|
else
|
|
24
46
|
raise PuppetLint::NoFix, "Not fixing"
|
|
25
47
|
end
|
|
@@ -182,12 +182,79 @@ describe 'fileserver' do
|
|
|
182
182
|
expect(problems).to have(1).problem
|
|
183
183
|
end
|
|
184
184
|
|
|
185
|
-
it 'should
|
|
186
|
-
expect(problems).to
|
|
185
|
+
it 'should fix the problem' do
|
|
186
|
+
expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
|
|
187
187
|
end
|
|
188
188
|
|
|
189
|
-
it 'should
|
|
190
|
-
expect(manifest).to eq(
|
|
189
|
+
it 'should add a newline to the end of the manifest' do
|
|
190
|
+
expect(manifest).to eq(
|
|
191
|
+
<<-EOS
|
|
192
|
+
file { 'foo':
|
|
193
|
+
ensure => file,
|
|
194
|
+
content => file("${module_name}/bar"),
|
|
195
|
+
}
|
|
196
|
+
EOS
|
|
197
|
+
)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
context 'code using a variable' do
|
|
202
|
+
let(:code) {
|
|
203
|
+
<<-EOS
|
|
204
|
+
file { 'foo':
|
|
205
|
+
ensure => file,
|
|
206
|
+
source => "puppet:///modules/foo/${bar}",
|
|
207
|
+
}
|
|
208
|
+
EOS
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
it 'should detect a single problem' do
|
|
212
|
+
expect(problems).to have(1).problem
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it 'should fix the problem' do
|
|
216
|
+
expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it 'should add a newline to the end of the manifest' do
|
|
220
|
+
expect(manifest).to eq(
|
|
221
|
+
<<-EOS
|
|
222
|
+
file { 'foo':
|
|
223
|
+
ensure => file,
|
|
224
|
+
content => file("foo/${bar}"),
|
|
225
|
+
}
|
|
226
|
+
EOS
|
|
227
|
+
)
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
context 'code using two variables' do
|
|
232
|
+
let(:code) {
|
|
233
|
+
<<-EOS
|
|
234
|
+
file { 'foo':
|
|
235
|
+
ensure => file,
|
|
236
|
+
source => "puppet:///modules/${module_name}/${bar}",
|
|
237
|
+
}
|
|
238
|
+
EOS
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
it 'should detect a single problem' do
|
|
242
|
+
expect(problems).to have(1).problem
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'should fix the problem' do
|
|
246
|
+
expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it 'should add a newline to the end of the manifest' do
|
|
250
|
+
expect(manifest).to eq(
|
|
251
|
+
<<-EOS
|
|
252
|
+
file { 'foo':
|
|
253
|
+
ensure => file,
|
|
254
|
+
content => file("${module_name}/${bar}"),
|
|
255
|
+
}
|
|
256
|
+
EOS
|
|
257
|
+
)
|
|
191
258
|
end
|
|
192
259
|
end
|
|
193
260
|
|