puppet-lint-absolute_template_path 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 869f58dd0ff55cbdcc027e57a37134f48ea56ec3
4
+ data.tar.gz: ad3c0f145b2ba3b983575a337909dded4854218e
5
+ SHA512:
6
+ metadata.gz: 5478f4591bc33c21e9578dff93c99b0aad6ea7c3337345cfde77946093b5e5098c42b0a98b8c7f424c74bd1fe34aaa2db91069375889fba4e3a879885d65b9af
7
+ data.tar.gz: 05608cc37772f0b82ce8ab5036bd0fff3835c5104907d7ecbac5754e996c3f132e1a10e3857fbf79e8cbf0236429ec7ceda291f7aeaab6849e64c4fd29e47690
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 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,23 @@
1
+ # puppet-lint absolute template path check
2
+
3
+ A new check for puppet-lint that checks template paths are in the
4
+ relative `template('example/template.erb')` form rather than the absolute
5
+ `template('/etc/puppet/modules/example/templates/template.erb')` format.
6
+
7
+ ## Installation
8
+
9
+ To use this plugin add the following line to your Gemfile
10
+
11
+ ```ruby
12
+ gem 'puppet-lint-absolute_template_path'
13
+ ```
14
+
15
+ and then run `bundle install`.
16
+
17
+ ## Usage
18
+
19
+ This plugin provides a new check to `puppet-lint`.
20
+
21
+ ```
22
+ WARNING: template module paths should be relative, not absolute on line 5
23
+ ```
@@ -0,0 +1,29 @@
1
+ PuppetLint.new_check(:absolute_template_path) do
2
+ def check
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|
8
+
9
+ value_token = content_token.next_code_token.next_code_token
10
+
11
+ if value_token.value.start_with? 'template'
12
+ template_path = value_token.next_code_token.next_code_token.value
13
+
14
+ if template_path.start_with? '/'
15
+
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
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'absolute_template_path' do
4
+
5
+ let(:msg) { 'template module paths should be relative, not absolute' }
6
+
7
+ context 'with fix disabled' do
8
+ context 'template with a relative module path' do
9
+ let(:code) do
10
+ <<-EOS
11
+ class template_tester {
12
+ file { '/tmp/template':
13
+ content => template('example/template.erb'),
14
+ }
15
+ }
16
+ EOS
17
+ end
18
+
19
+ it 'should not detect any problems' do
20
+ expect(problems).to have(0).problems
21
+ end
22
+ end
23
+
24
+ context 'template with an absolute module path' do
25
+ let(:code) do
26
+ <<-EOS
27
+ class template_tester {
28
+ file { '/tmp/template':
29
+ content => template('/etc/puppet/modules/example/template.erb'),
30
+ }
31
+ }
32
+ EOS
33
+ end
34
+
35
+ it 'should detect a single problem' do
36
+ expect(problems).to have(1).problem
37
+ end
38
+
39
+ it 'should create a warning' do
40
+ expect(problems).to contain_warning(msg).on_line(3).in_column(26)
41
+ end
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,3 @@
1
+ require 'puppet-lint'
2
+
3
+ PuppetLint::Plugins.load_spec_helper
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-lint-absolute_template_path
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dean Wilson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-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
+ 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"
85
+ email: dean.wilson@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - README.md
91
+ - LICENSE
92
+ - lib/puppet-lint/plugins/absolute_template_path.rb
93
+ - spec/spec_helper.rb
94
+ - spec/puppet-lint/plugins/absolute_template_path_spec.rb
95
+ homepage: https://github.com/deanwilson/puppet-lint-absolute_template_path
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.1.11
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: puppet-lint absolute template path check
119
+ test_files:
120
+ - spec/spec_helper.rb
121
+ - spec/puppet-lint/plugins/absolute_template_path_spec.rb