puppet-lint-fileserver-check 1.1.0 → 1.1.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f29951ef181d127ebc193fec7eed34353148bec0
|
4
|
+
data.tar.gz: 617f106be6a01288f8d802c5e394d4eab9eab128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f532ff5320204e0817e359f62ef1c4a89e27926a8126aa3fc748baf5490a78f60a4cbc5a8846c3f1a2fce27a1a9313d6647dc2e96f73edc0c1e9a0f60fa9d1e
|
7
|
+
data.tar.gz: 1d41a86a47f7fbf9cc480c9a6a36b6ef558fdda66ab0b9a931359c5b1cb6c6c56d881c3cf3926013f7291f1b93c9a0df109d15d17323cf56245f8baf26060345
|
@@ -16,32 +16,36 @@ PuppetLint.new_check(:fileserver) do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def fix(problem)
|
19
|
-
if problem[:resource][:type].value == 'file'
|
20
|
-
problem[:token].
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
problem[:token].
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
t
|
19
|
+
if problem[:resource][:type].value == 'file'
|
20
|
+
if problem[:token].type == :SSTRING
|
21
|
+
problem[:token].prev_code_token.prev_code_token.value = 'content'
|
22
|
+
problem[:token].value.sub!(%r{^puppet:///modules/(.*)}, "file('\\1')")
|
23
|
+
problem[:token].type = :NAME
|
24
|
+
elsif problem[:token].type == :DQPRE
|
25
|
+
problem[:token].prev_code_token.prev_code_token.value = 'content'
|
26
|
+
file = PuppetLint::Lexer::Token.new(
|
27
|
+
:NAME, 'file',
|
28
|
+
problem[:token].line, problem[:token].column+1
|
29
|
+
)
|
30
|
+
lparen = PuppetLint::Lexer::Token.new(
|
31
|
+
:LPAREN, '(',
|
32
|
+
problem[:token].line, problem[:token].column+1
|
33
|
+
)
|
34
|
+
rparen = PuppetLint::Lexer::Token.new(
|
35
|
+
:RPAREN, ')',
|
36
|
+
problem[:token].line, problem[:token].column+1
|
37
|
+
)
|
38
|
+
tokens.insert(tokens.index(problem[:token]), file)
|
39
|
+
tokens.insert(tokens.index(problem[:token]), lparen)
|
40
|
+
problem[:token].value.sub!(%r{^puppet:///modules/}, '')
|
41
|
+
t = problem[:token].next_code_token
|
42
|
+
while t.type != :DQPOST
|
43
|
+
t = t.next_code_token
|
44
|
+
end
|
45
|
+
tokens.insert(tokens.index(t)+1, rparen)
|
46
|
+
else
|
47
|
+
raise PuppetLint::NoFix, "Not fixing"
|
43
48
|
end
|
44
|
-
tokens.insert(tokens.index(t)+1, rparen)
|
45
49
|
else
|
46
50
|
raise PuppetLint::NoFix, "Not fixing"
|
47
51
|
end
|
@@ -89,6 +89,24 @@ describe 'fileserver' do
|
|
89
89
|
expect(problems).to contain_warning(msg).on_line(2).in_column(26)
|
90
90
|
end
|
91
91
|
end
|
92
|
+
|
93
|
+
context 'when using fileserver not in file resource with variables' do
|
94
|
+
let(:code) {
|
95
|
+
<<-EOS
|
96
|
+
foo { 'foo':
|
97
|
+
file_source => "puppet:///${module_name}/foo/bar",
|
98
|
+
}
|
99
|
+
EOS
|
100
|
+
}
|
101
|
+
|
102
|
+
it 'should detect a single problem' do
|
103
|
+
expect(problems).to have(1).problem
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should create a warning' do
|
107
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(26)
|
108
|
+
end
|
109
|
+
end
|
92
110
|
end
|
93
111
|
|
94
112
|
context 'with fix enabled' do
|
@@ -279,5 +297,27 @@ describe 'fileserver' do
|
|
279
297
|
expect(manifest).to eq(code)
|
280
298
|
end
|
281
299
|
end
|
300
|
+
|
301
|
+
context 'when using fileserver not in file resource with variables' do
|
302
|
+
let(:code) {
|
303
|
+
<<-EOS
|
304
|
+
foo { 'foo':
|
305
|
+
file_source => "puppet:///${module_name}/foo/bar",
|
306
|
+
}
|
307
|
+
EOS
|
308
|
+
}
|
309
|
+
|
310
|
+
it 'should detect a single problem' do
|
311
|
+
expect(problems).to have(1).problem
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'should create a warning' do
|
315
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(26)
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'should not modify the manifest' do
|
319
|
+
expect(manifest).to eq(code)
|
320
|
+
end
|
321
|
+
end
|
282
322
|
end
|
283
323
|
end
|