puppet-lint-no_erb_template-check 0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +37 -0
- data/lib/puppet-lint/plugins/no_erb_template.rb +21 -0
- data/spec/puppet-lint/plugins/no_erb_template_spec.rb +81 -0
- data/spec/spec_helper.rb +3 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8088bbada0b6269c1305217096d8133935a3feef
|
4
|
+
data.tar.gz: 1e8ec31a837808b64604a256098b82082891cedd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c02fd232a11bf53384c8e560f80c41d1cf67c98193c9f71f4a58e6cc03eaf49f5b2b8c6460c597f1178111b621fc51039547ee80e3d93fc4955e502be65dc868
|
7
|
+
data.tar.gz: 43a3ac6962d06eb3a3ec5b92193faa5fc738b3df3cdcc909050f4c54eab3a3500dba7c6bf91f6fac9179232d905796d910ab47ef7f0a272ef7f1b25ac4904937
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Dean Wilson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# puppet-lint no ERB templates check
|
2
|
+
|
3
|
+
As part of the migration to a cleaner, Puppet 4 enhanced, code base one
|
4
|
+
of the suggestions is to move from the old ERB (Embedded Ruby)
|
5
|
+
templates to the newer, kinder, gentler `epp` (Embedded Puppet
|
6
|
+
Programming) equivalents. You can find more details in the
|
7
|
+
[Templating with Embedded Puppet Programming Language - EPP](http://puppet-on-the-edge.blogspot.co.uk/2014/03/templating-with-embedded-puppet.html) blog post.
|
8
|
+
|
9
|
+
The lint check in this plugin will raise a warning anywhere a
|
10
|
+
`template()` or `inline_template()` function call is found in your
|
11
|
+
manifests. It's worth noting that this plugin will probably raise a lot
|
12
|
+
of warnings if you use external modules that maintain Puppet 3
|
13
|
+
compatibility; and will be of most use in new, Puppet 4 only code bases.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
To use this plugin add the following line to your Gemfile
|
18
|
+
|
19
|
+
gem 'puppet-lint-no_erb_template-check'
|
20
|
+
|
21
|
+
and then run `bundle install`.
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
This plugin provides two new checks to `puppet-lint`.
|
26
|
+
|
27
|
+
'inline_template() function call. Use inline_epp() instead'
|
28
|
+
|
29
|
+
'template() function call. Use epp() instead'
|
30
|
+
|
31
|
+
#### Author
|
32
|
+
|
33
|
+
[Dean Wilson](http://www.unixdaemon.net)
|
34
|
+
|
35
|
+
### License
|
36
|
+
|
37
|
+
* MIT
|
@@ -0,0 +1,21 @@
|
|
1
|
+
PuppetLint.new_check(:no_erb_template) do
|
2
|
+
def check
|
3
|
+
functions = ['template', 'inline_template']
|
4
|
+
|
5
|
+
tokens.select { |t| t.type == :NAME and functions.include? t.value }.each do |function_token|
|
6
|
+
next unless function_token.next_code_token.type == :LPAREN
|
7
|
+
|
8
|
+
key_token = function_token.next_code_token.next_code_token
|
9
|
+
|
10
|
+
# display the new, epp, version of the function
|
11
|
+
original_function = function_token.value
|
12
|
+
new_func = function_token.value.sub(/template/, 'epp')
|
13
|
+
|
14
|
+
notify :warning, {
|
15
|
+
message: "#{original_function}() function call. Use #{new_func}() instead",
|
16
|
+
line: key_token.line,
|
17
|
+
column: key_token.column,
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'no_erb_template' do
|
4
|
+
context 'class with no template calls' do
|
5
|
+
let(:code) do
|
6
|
+
<<-EOS
|
7
|
+
class no_template_calls {
|
8
|
+
file { '/tmp/foo':
|
9
|
+
content => 'bar',
|
10
|
+
}
|
11
|
+
}
|
12
|
+
EOS
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should not detect any problems' do
|
16
|
+
expect(problems).to have(0).problems
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'class with an epp template call' do
|
21
|
+
let(:code) do
|
22
|
+
<<-EOS
|
23
|
+
class epp_call {
|
24
|
+
file { '/tmp/foo':
|
25
|
+
content => epp('mymodule/bar.epp'),
|
26
|
+
}
|
27
|
+
}
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should not detect any problems' do
|
32
|
+
expect(problems).to have(0).problems
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# and these should cause failiures
|
37
|
+
|
38
|
+
context 'class with a template call' do
|
39
|
+
let(:msg) { 'template() function call. Use epp() instead' }
|
40
|
+
|
41
|
+
let(:code) do
|
42
|
+
<<-EOS
|
43
|
+
class template_call {
|
44
|
+
file { '/tmp/foo':
|
45
|
+
content => template('mymodule/bar.epp'),
|
46
|
+
}
|
47
|
+
}
|
48
|
+
EOS
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should detect a single problem' do
|
52
|
+
expect(problems).to have(1).problem
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should create an error' do
|
56
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(33)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'class with an inline_template call' do
|
61
|
+
let(:msg) { 'inline_template() function call. Use inline_epp() instead' }
|
62
|
+
|
63
|
+
let(:code) do
|
64
|
+
<<-EOS
|
65
|
+
class template_call {
|
66
|
+
file { '/tmp/foo':
|
67
|
+
content => inline_template('This is a rubbish template'),
|
68
|
+
}
|
69
|
+
}
|
70
|
+
EOS
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should detect a single problem' do
|
74
|
+
expect(problems).to have(1).problem
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should create an error' do
|
78
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(40)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-lint-no_erb_template-check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dean Wilson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: puppet-lint
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-its
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-collection_matchers
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: |2
|
112
|
+
Extends puppet-lint to ensure there are no calls to the template
|
113
|
+
or inline_template function as an aid to migrating to epp templates.
|
114
|
+
email: dean.wilson@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- LICENSE
|
120
|
+
- README.md
|
121
|
+
- lib/puppet-lint/plugins/no_erb_template.rb
|
122
|
+
- spec/puppet-lint/plugins/no_erb_template_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: https://github.com/deanwilson/puppet-lint-no_erb_template-check
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.8
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: puppet-lint no_erb_template check
|
148
|
+
test_files:
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- spec/puppet-lint/plugins/no_erb_template_spec.rb
|