puppet-lint-resource_reference_syntax 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7535ed7a11c71f153bf11d5dfd35a06bef5044e0
|
4
|
+
data.tar.gz: ca972b966ba85a130de583157c35a2cdcfaa34b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d24d371e282aab9727bd12d89f3799ab03b6693538d616670ad1b5d15245b612aeb7372ede3bbf2d7a9ba935a58d43f550f1ea87970e0c0bf20d39630239703
|
7
|
+
data.tar.gz: 2c622e331ef8cb8a0b3c3a5c03d84b9724a6f05dfe86fad30b3b6a85bd289f19d9b84eea264a6b7ebf0c43d196ef21803bbeb9017e6805f6b373c98105f9ca7b
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -23,6 +23,13 @@ This plugin provides two new checks to `puppet-lint`.
|
|
23
23
|
This check will raise an error for any resource reference that has a whitespace
|
24
24
|
between the Type reference and the opening bracket.
|
25
25
|
|
26
|
+
e.g. the following code is NOT good for Puppet 4:
|
27
|
+
|
28
|
+
```
|
29
|
+
require => File ['/etc/motd']
|
30
|
+
```
|
31
|
+
and will result in the following error:
|
32
|
+
|
26
33
|
```
|
27
34
|
ERROR: whitespce between reference type and title on line 4
|
28
35
|
```
|
@@ -33,7 +40,22 @@ ERROR: whitespce between reference type and title on line 4
|
|
33
40
|
|
34
41
|
This check will raise an error for any resource reference that uses the title with capital letter without enclosed quotes.
|
35
42
|
|
43
|
+
e.g. the following code will not work on Puppet 4:
|
44
|
+
```
|
45
|
+
require => Service[Apache],
|
46
|
+
require => Service[Apache, Mysql],
|
47
|
+
require => Service[apache]
|
48
|
+
```
|
49
|
+
and will result in the following error:
|
36
50
|
```
|
37
51
|
ERROR: resource reference with title with capital letter on line 4
|
38
52
|
```
|
39
53
|
|
54
|
+
The following references are good code for Puppet 4:
|
55
|
+
|
56
|
+
```
|
57
|
+
require => Service['apache'],
|
58
|
+
require => Service['apache', 'mysql'],
|
59
|
+
require => [ Service['apache'], Service['mysql'] ],
|
60
|
+
```
|
61
|
+
|
@@ -5,7 +5,7 @@ PuppetLint.new_check(:resource_reference_without_title_capital) do
|
|
5
5
|
['require', 'subscribe', 'notify', 'before', 'consume', 'export'].include? param_token.value
|
6
6
|
}.each do |param_token|
|
7
7
|
value_token = param_token.next_code_token.next_code_token.next_code_token.next_token
|
8
|
-
unless value_token.type == :SSTRING or value_token.type == :VARIABLE
|
8
|
+
unless value_token.type == :SSTRING or value_token.type == :VARIABLE or value_token.next_token.type == :SSTRING
|
9
9
|
notify :error, {
|
10
10
|
:message => 'resource reference with title with capital letter',
|
11
11
|
:line => value_token.line,
|
@@ -19,6 +19,22 @@ describe 'resource_reference_without_title_capital' do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
context 'a proper reference as array in quotes' do
|
23
|
+
let(:code) { "file { 'foo': ensure => file, notify => Title['one', 'two'],}" }
|
24
|
+
|
25
|
+
it 'should detect no problem' do
|
26
|
+
expect(problems).to have(0).problem
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'multiple proper references as array in quotes' do
|
31
|
+
let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title['two'] ],}" }
|
32
|
+
|
33
|
+
it 'should detect no problem' do
|
34
|
+
expect(problems).to have(0).problem
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
22
38
|
context 'a proper reference as variable' do
|
23
39
|
let(:code) { "file { 'foo': ensure => file, notify => Title[$foo_var],}" }
|
24
40
|
|
@@ -40,6 +56,32 @@ describe 'resource_reference_without_title_capital' do
|
|
40
56
|
end
|
41
57
|
end
|
42
58
|
|
59
|
+
context 'resource reference with title as array of capital letters' do
|
60
|
+
let(:msg) { 'resource reference with title with capital letter' }
|
61
|
+
let(:code) { "file { 'foo': ensure => file, notify => Title[One, Two],}" }
|
62
|
+
|
63
|
+
it 'should only detect a single problem' do
|
64
|
+
expect(problems).to have(1).problem
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should create an error' do
|
68
|
+
expect(problems).to contain_error(msg).on_line(1)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'resource reference with title as array of resource references with capital letters' do
|
73
|
+
let(:msg) { 'resource reference with title with capital letter' }
|
74
|
+
let(:code) { "file { 'foo': ensure => file, notify => [Title[One], Title[Two],]}" }
|
75
|
+
|
76
|
+
it 'should only detect a single problem' do
|
77
|
+
expect(problems).to have(1).problem
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should create an error' do
|
81
|
+
expect(problems).to contain_error(msg).on_line(1)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
43
85
|
context 'resource reference with title without quotes' do
|
44
86
|
let(:msg) { 'resource reference with title with capital letter' }
|
45
87
|
let(:code) { "file { 'foo': ensure => file, notify => Title[one],}" }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-resource_reference_syntax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Alfke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -87,6 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".rspec"
|
90
91
|
- LICENSE
|
91
92
|
- README.md
|
92
93
|
- lib/puppet-lint/plugins/resource_reference_without_title_capital.rb
|