puppet-lint-explicit_hiera_class_param_lookup-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
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 25f922c2cb240bc79774e4407794ebd6b09cb6b4
|
4
|
+
data.tar.gz: 1185f445dd37b80d5fa737bb25b1d43624a70325
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2696348e5561792596abe245b667b2abbe056d8a2c8b4ecc1ab9ae44806eb471e75e1739d3b6c7805d90e1901b2f1dd5bbb6f030e775f1ea7f88e3ba7b1f2912
|
7
|
+
data.tar.gz: dd5cc305e7468711d443b52607c2bac50d768f3375fc7ac9cd10e54cd47b758b83af79e108732637a0008e29073899c99d637a8d7e13c71a24c9f255a06987c5
|
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,40 @@
|
|
1
|
+
# puppet-lint explicit Hiera class parameter lookup check
|
2
|
+
|
3
|
+
Extends puppet-lint to ensure there are no explicit calls to hiera()
|
4
|
+
in the class parameters.
|
5
|
+
|
6
|
+
In our code base we would rather have a class lookup values for its
|
7
|
+
parameters using Puppets automatic data binding functionality rather than
|
8
|
+
scatter a number of direct, unpredictably name spaced, hiera calls
|
9
|
+
throughout our manifests. This puppet-lint plugin helps us with that goal by
|
10
|
+
finding any explicit `hiera` calls in a classes parameter section.
|
11
|
+
|
12
|
+
class no_explicit_lookups (
|
13
|
+
$my_content = hiera('my::nested::key', 'baz')
|
14
|
+
) {
|
15
|
+
file { '/tmp/foo':
|
16
|
+
content => $my_content,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
To use this plugin add the following line to your Gemfile
|
23
|
+
|
24
|
+
gem 'puppet-lint-explicit_hiera_class_param_lookup-check'
|
25
|
+
|
26
|
+
and then run `bundle install`.
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
This plugin provides a new check to `puppet-lint`.
|
31
|
+
|
32
|
+
explicit hiera() lookup of my::sample::key
|
33
|
+
|
34
|
+
#### Author
|
35
|
+
|
36
|
+
[Dean Wilson](http://www.unixdaemon.net)
|
37
|
+
|
38
|
+
### License
|
39
|
+
|
40
|
+
* MIT
|
@@ -0,0 +1,20 @@
|
|
1
|
+
PuppetLint.new_check(:explicit_hiera_class_param_lookup) do
|
2
|
+
def check
|
3
|
+
class_indexes.each do |class_idx|
|
4
|
+
|
5
|
+
class_idx[:param_tokens].select { |t|
|
6
|
+
t.type == :NAME and t.value == 'hiera'
|
7
|
+
}.each do |token|
|
8
|
+
|
9
|
+
hiera_key = token.next_code_token.next_code_token
|
10
|
+
|
11
|
+
notify :error, {
|
12
|
+
:message => "explicit hiera() lookup of #{hiera_key.value}",
|
13
|
+
:line => hiera_key.line,
|
14
|
+
:column => hiera_key.column,
|
15
|
+
}
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'explicit_hiera_class_param_lookup' do
|
4
|
+
|
5
|
+
context 'class with no explicit hiera() lookups' do
|
6
|
+
let(:code) do
|
7
|
+
<<-EOS
|
8
|
+
class no_explicit_lookups(
|
9
|
+
$my_content = undef
|
10
|
+
) {
|
11
|
+
file { '/tmp/foo':
|
12
|
+
content => 'bar',
|
13
|
+
}
|
14
|
+
}
|
15
|
+
EOS
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not detect any problems' do
|
19
|
+
expect(problems).to have(0).problems
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
context 'class with an explicit hiera() lookup' do
|
25
|
+
let(:msg) { "explicit hiera() lookup of my::nested::key" }
|
26
|
+
|
27
|
+
let(:code) do
|
28
|
+
<<-EOS
|
29
|
+
class no_explicit_lookups(
|
30
|
+
$my_content = hiera('my::nested::key', 'baz')
|
31
|
+
) {
|
32
|
+
file { '/tmp/foo':
|
33
|
+
content => $my_content,
|
34
|
+
}
|
35
|
+
}
|
36
|
+
EOS
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should detect a single problem' do
|
40
|
+
expect(problems).to have(1).problem
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should create an error' do
|
44
|
+
expect(problems).to contain_error(msg).on_line(2).in_column(31)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-lint-explicit_hiera_class_param_lookup-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-06-28 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 explicit calls to hiera()
|
113
|
+
in the class parameters.
|
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/explicit_hiera_class_param_lookup.rb
|
122
|
+
- spec/puppet-lint/plugins/puppet-lint-explicit_hiera_class_param_lookup_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: https://github.com/deanwilson/puppet-lint-explicit_hiera_class_param_lookup-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 explicit_hiera_class_param_lookup check
|
148
|
+
test_files:
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- spec/puppet-lint/plugins/puppet-lint-explicit_hiera_class_param_lookup_spec.rb
|
151
|
+
has_rdoc:
|