puppet-lint-absolute_template_path 1.0.0 → 2.0.0

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
- SHA1:
3
- metadata.gz: 869f58dd0ff55cbdcc027e57a37134f48ea56ec3
4
- data.tar.gz: ad3c0f145b2ba3b983575a337909dded4854218e
2
+ SHA256:
3
+ metadata.gz: 02a0cdec7239448a8e68128530bfe37d0e08015e2918d2b4c6727cccb030fa7b
4
+ data.tar.gz: 7fdea9bcf4663a099fdf96e396197d987650e52b186aa08f4acfe6aa2719b8a4
5
5
  SHA512:
6
- metadata.gz: 5478f4591bc33c21e9578dff93c99b0aad6ea7c3337345cfde77946093b5e5098c42b0a98b8c7f424c74bd1fe34aaa2db91069375889fba4e3a879885d65b9af
7
- data.tar.gz: 05608cc37772f0b82ce8ab5036bd0fff3835c5104907d7ecbac5754e996c3f132e1a10e3857fbf79e8cbf0236429ec7ceda291f7aeaab6849e64c4fd29e47690
6
+ metadata.gz: 9acf95528a3d812914e8ee0cd083a2d8d65159e289286612701e4837813dbff0662a3decb71ef3e597972d9f6e3b30e9dd7971e255e8035212d20f7e61e4d1bc
7
+ data.tar.gz: 7993374239e66964b7c613839e6c0442267f6f84d1d54251363b9af85fc1c4ebcfa4ada566fc603b0065386b7d75805b5912dfcb01f1217732298490494dbebf
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # puppet-lint absolute template path check
2
2
 
3
+ [![Actions Status](https://github.com/deanwilson/puppet-lint-absolute_template_path-check/workflows/Ruby/badge.svg)](https://github.com/deanwilson/puppet-lint-absolute_template_path-check/actions)
4
+
3
5
  A new check for puppet-lint that checks template paths are in the
4
6
  relative `template('example/template.erb')` form rather than the absolute
5
7
  `template('/etc/puppet/modules/example/templates/template.erb')` format.
@@ -21,3 +23,12 @@ This plugin provides a new check to `puppet-lint`.
21
23
  ```
22
24
  WARNING: template module paths should be relative, not absolute on line 5
23
25
  ```
26
+
27
+ ## Other puppet-lint plugins
28
+
29
+ You can find a list of my `puppet-lint` plugins in the
30
+ [unixdaemon puppet-lint-plugins](https://github.com/deanwilson/unixdaemon-puppet-lint-plugins) repo.
31
+
32
+ ### Author
33
+
34
+ [Dean Wilson](http://www.unixdaemon.net)
@@ -1,28 +1,28 @@
1
1
  PuppetLint.new_check(:absolute_template_path) do
2
2
  def check
3
3
  resource_indexes.each do |resource|
4
- if resource[:type].value == "file"
5
- resource[:param_tokens].select { |param_token|
6
- param_token.value == 'content'
7
- }.each do |content_token|
4
+ next unless resource[:type].value == 'file'
8
5
 
9
- value_token = content_token.next_code_token.next_code_token
6
+ content_tokens = resource[:param_tokens].select { |pt| pt.value == 'content' }
10
7
 
11
- if value_token.value.start_with? 'template'
12
- template_path = value_token.next_code_token.next_code_token.value
8
+ content_tokens.each do |content_token|
9
+ value_token = content_token.next_code_token.next_code_token
13
10
 
14
- if template_path.start_with? '/'
11
+ next unless value_token.value.start_with? 'template'
15
12
 
16
- notify :warning, {
17
- :message => 'template module paths should be relative, not absolute',
18
- :line => value_token.line,
19
- :column => value_token.column,
20
- :param_token => content_token,
21
- :value_token => value_token,
22
- }
23
- end
24
- end
25
- end
13
+ template_path = value_token.next_code_token.next_code_token.value
14
+
15
+ next unless template_path.start_with? '/' # skip relative paths
16
+
17
+ # if we made it here it's a file resource with a template parameter
18
+ # that begins with an absolute path, so raise a lint issue for it.
19
+ notify :warning, {
20
+ message: 'template module paths should be relative, not absolute',
21
+ line: value_token.line,
22
+ column: value_token.column,
23
+ param_token: content_token,
24
+ value_token: value_token,
25
+ }
26
26
  end
27
27
  end
28
28
  end
@@ -1,45 +1,77 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'absolute_template_path' do
4
-
5
4
  let(:msg) { 'template module paths should be relative, not absolute' }
6
5
 
6
+ context 'when the manifest has no file resources' do
7
+ let(:code) do
8
+ <<-TEST_CLASS
9
+ class no_file_resource {
10
+ host { 'syslog':
11
+ ip => '10.10.10.10',
12
+ }
13
+ }
14
+ TEST_CLASS
15
+ end
16
+
17
+ it 'does not detect any problems' do
18
+ expect(problems).to have(0).problems
19
+ end
20
+ end
21
+
22
+ context 'with file resource but no template call' do
23
+ context 'when the template has a relative module path' do
24
+ let(:code) do
25
+ <<-TEST_CLASS
26
+ class template_tester {
27
+ file { '/tmp/template':
28
+ content => 'A static string',
29
+ }
30
+ }
31
+ TEST_CLASS
32
+ end
33
+
34
+ it 'detects no problems' do
35
+ expect(problems).to have(0).problems
36
+ end
37
+ end
38
+ end
39
+
7
40
  context 'with fix disabled' do
8
- context 'template with a relative module path' do
41
+ context 'when the template has a relative module path' do
9
42
  let(:code) do
10
- <<-EOS
43
+ <<-TEST_CLASS
11
44
  class template_tester {
12
45
  file { '/tmp/template':
13
46
  content => template('example/template.erb'),
14
47
  }
15
48
  }
16
- EOS
49
+ TEST_CLASS
17
50
  end
18
51
 
19
- it 'should not detect any problems' do
52
+ it 'detects no problems' do
20
53
  expect(problems).to have(0).problems
21
54
  end
22
55
  end
23
56
 
24
- context 'template with an absolute module path' do
57
+ context 'when the template has an absolute module path' do
25
58
  let(:code) do
26
- <<-EOS
59
+ <<-TEST_CLASS
27
60
  class template_tester {
28
61
  file { '/tmp/template':
29
62
  content => template('/etc/puppet/modules/example/template.erb'),
30
63
  }
31
64
  }
32
- EOS
65
+ TEST_CLASS
33
66
  end
34
67
 
35
- it 'should detect a single problem' do
68
+ it 'detects a single problem' do
36
69
  expect(problems).to have(1).problem
37
70
  end
38
71
 
39
- it 'should create a warning' do
40
- expect(problems).to contain_warning(msg).on_line(3).in_column(26)
72
+ it 'creates a warning' do
73
+ expect(problems).to contain_warning(msg).on_line(3).in_column(26)
41
74
  end
42
75
  end
43
76
  end
44
-
45
77
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,8 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ enable_coverage :branch
4
+ end
5
+
1
6
  require 'puppet-lint'
2
7
 
3
8
  PuppetLint::Plugins.load_spec_helper
metadata CHANGED
@@ -1,98 +1,176 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-absolute_template_path
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-04 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 13.0.0
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 13.0.0
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: rspec
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
- - - ~>
51
+ - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: '3.0'
53
+ version: 3.12.0
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
- - - ~>
58
+ - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: '3.0'
60
+ version: 3.12.0
41
61
  - !ruby/object:Gem::Dependency
42
- name: rspec-its
62
+ name: rspec-collection_matchers
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
45
- - - ~>
65
+ - - "~>"
46
66
  - !ruby/object:Gem::Version
47
67
  version: '1.0'
48
68
  type: :development
49
69
  prerelease: false
50
70
  version_requirements: !ruby/object:Gem::Requirement
51
71
  requirements:
52
- - - ~>
72
+ - - "~>"
53
73
  - !ruby/object:Gem::Version
54
74
  version: '1.0'
55
75
  - !ruby/object:Gem::Dependency
56
- name: rspec-collection_matchers
76
+ name: rspec-its
57
77
  requirement: !ruby/object:Gem::Requirement
58
78
  requirements:
59
- - - ~>
79
+ - - "~>"
60
80
  - !ruby/object:Gem::Version
61
81
  version: '1.0'
62
82
  type: :development
63
83
  prerelease: false
64
84
  version_requirements: !ruby/object:Gem::Requirement
65
85
  requirements:
66
- - - ~>
86
+ - - "~>"
67
87
  - !ruby/object:Gem::Version
68
88
  version: '1.0'
69
89
  - !ruby/object:Gem::Dependency
70
- name: rake
90
+ name: rspec-json_expectations
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2.2'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.2'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.52.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.52.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-rake
71
119
  requirement: !ruby/object:Gem::Requirement
72
120
  requirements:
73
- - - '>='
121
+ - - ">="
74
122
  - !ruby/object:Gem::Version
75
123
  version: '0'
76
124
  type: :development
77
125
  prerelease: false
78
126
  version_requirements: !ruby/object:Gem::Requirement
79
127
  requirements:
80
- - - '>='
128
+ - - ">="
81
129
  - !ruby/object:Gem::Version
82
130
  version: '0'
83
- description: " A new check for puppet-lint that checks all template paths are in
84
- the\n template('example/template.erb') form rather than \n template('/etc/puppet/modules/example/templates/template.erb')\n"
131
+ - !ruby/object:Gem::Dependency
132
+ name: rubocop-rspec
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 2.22.0
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 2.22.0
145
+ - !ruby/object:Gem::Dependency
146
+ name: simplecov
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: 0.22.0
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: 0.22.0
159
+ description: |2
160
+ A new check for puppet-lint that checks all template paths are in the
161
+ template('example/template.erb') form rather than
162
+ template('/etc/puppet/modules/example/templates/template.erb')
85
163
  email: dean.wilson@gmail.com
86
164
  executables: []
87
165
  extensions: []
88
166
  extra_rdoc_files: []
89
167
  files:
90
- - README.md
91
168
  - LICENSE
169
+ - README.md
92
170
  - lib/puppet-lint/plugins/absolute_template_path.rb
93
- - spec/spec_helper.rb
94
171
  - spec/puppet-lint/plugins/absolute_template_path_spec.rb
95
- homepage: https://github.com/deanwilson/puppet-lint-absolute_template_path
172
+ - spec/spec_helper.rb
173
+ homepage: https://github.com/deanwilson/puppet-lint-absolute_template_path-check
96
174
  licenses:
97
175
  - MIT
98
176
  metadata: {}
@@ -102,20 +180,19 @@ require_paths:
102
180
  - lib
103
181
  required_ruby_version: !ruby/object:Gem::Requirement
104
182
  requirements:
105
- - - '>='
183
+ - - ">="
106
184
  - !ruby/object:Gem::Version
107
- version: '0'
185
+ version: 2.7.0
108
186
  required_rubygems_version: !ruby/object:Gem::Requirement
109
187
  requirements:
110
- - - '>='
188
+ - - ">="
111
189
  - !ruby/object:Gem::Version
112
190
  version: '0'
113
191
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.1.11
192
+ rubygems_version: 3.1.6
116
193
  signing_key:
117
194
  specification_version: 4
118
195
  summary: puppet-lint absolute template path check
119
196
  test_files:
120
- - spec/spec_helper.rb
121
197
  - spec/puppet-lint/plugins/absolute_template_path_spec.rb
198
+ - spec/spec_helper.rb