puppet-lint-lookup_in_parameter-check 1.0.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
+ SHA256:
3
+ metadata.gz: 306b66e0da869127acdf80e59dbabefe5c58dacc396bf6e47f661c9e1d5c766a
4
+ data.tar.gz: ccd82125accb783e960bc3c5a89657247859da71bdd025055f9df4b426901bab
5
+ SHA512:
6
+ metadata.gz: 0b394aa75ca884ccc45d0118a53b434efeb95a1c9e780144c6d5d9f9ab72836f500f696031e523d1cbaa060a2770f784560778499c4e953559cfc049e3f07713
7
+ data.tar.gz: b7ea9768113811b52622c9c641b753107b86b2322f3e36c116b5545ce0a395a5e7307e7d4395b7d711c19c55ed53a4f4d279a05f8e2b25cc53cdfcb1fb6e2064
@@ -0,0 +1,252 @@
1
+ # Contribution guidelines
2
+
3
+ ## Table of contents
4
+
5
+ * [Contributing](#contributing)
6
+ * [Writing proper commits - short version](#writing-proper-commits-short-version)
7
+ * [Writing proper commits - long version](#writing-proper-commits-long-version)
8
+ * [Dependencies](#dependencies)
9
+ * [Note for OS X users](#note-for-os-x-users)
10
+ * [The test matrix](#the-test-matrix)
11
+ * [Syntax and style](#syntax-and-style)
12
+ * [Running the unit tests](#running-the-unit-tests)
13
+ * [Unit tests in docker](#unit-tests-in-docker)
14
+ * [Integration tests](#integration-tests)
15
+
16
+ This module has grown over time based on a range of contributions from
17
+ people using it. If you follow these contributing guidelines your patch
18
+ will likely make it into a release a little more quickly.
19
+
20
+ ## Contributing
21
+
22
+ Please note that this project is released with a Contributor Code of Conduct.
23
+ By participating in this project you agree to abide by its terms.
24
+ [Contributor Code of Conduct](https://voxpupuli.org/coc/).
25
+
26
+ * Fork the repo.
27
+ * Create a separate branch for your change.
28
+ * We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix).
29
+ * Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request.
30
+ * Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test.
31
+ * Squash your commits down into logical components. Make sure to rebase against our current master.
32
+ * Push the branch to your fork and submit a pull request.
33
+
34
+ Please be prepared to repeat some of these steps as our contributors review your code.
35
+
36
+ Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions!
37
+
38
+ ## Writing proper commits - short version
39
+
40
+ * Make commits of logical units.
41
+ * Check for unnecessary whitespace with "git diff --check" before committing.
42
+ * Commit using Unix line endings (check the settings around "crlf" in git-config(1)).
43
+ * Do not check in commented out code or unneeded files.
44
+ * The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop.
45
+ * Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message".
46
+ * The body should provide a meaningful commit message, which:
47
+ *uses the imperative, present tense: `change`, not `changed` or `changes`.
48
+ * includes motivation for the change, and contrasts its implementation with the previous behavior.
49
+ * Make sure that you have tests for the bug you are fixing, or feature you are adding.
50
+ * Make sure the test suites passes after your commit:
51
+ * When introducing a new feature, make sure it is properly documented in the README.md
52
+
53
+ ## Writing proper commits - long version
54
+
55
+ 1. Make separate commits for logically separate changes.
56
+
57
+ Please break your commits down into logically consistent units
58
+ which include new or changed tests relevant to the rest of the
59
+ change. The goal of doing this is to make the diff easier to
60
+ read for whoever is reviewing your code. In general, the easier
61
+ your diff is to read, the more likely someone will be happy to
62
+ review it and get it into the code base.
63
+
64
+ If you are going to refactor a piece of code, please do so as a
65
+ separate commit from your feature or bug fix changes.
66
+
67
+ We also really appreciate changes that include tests to make
68
+ sure the bug is not re-introduced, and that the feature is not
69
+ accidentally broken.
70
+
71
+ Describe the technical detail of the change(s). If your
72
+ description starts to get too long, that is a good sign that you
73
+ probably need to split up your commit into more finely grained
74
+ pieces.
75
+
76
+ Commits which plainly describe the things which help
77
+ reviewers check the patch and future developers understand the
78
+ code are much more likely to be merged in with a minimum of
79
+ bike-shedding or requested changes. Ideally, the commit message
80
+ would include information, and be in a form suitable for
81
+ inclusion in the release notes for the version of Puppet that
82
+ includes them.
83
+
84
+ Please also check that you are not introducing any trailing
85
+ whitespace or other "whitespace errors". You can do this by
86
+ running "git diff --check" on your changes before you commit.
87
+
88
+ 2. Sending your patches
89
+
90
+ To submit your changes via a GitHub pull request, we _highly_
91
+ recommend that you have them on a topic branch, instead of
92
+ directly on `master`.
93
+ It makes things much easier to keep track of, especially if
94
+ you decide to work on another thing before your first change
95
+ is merged in.
96
+
97
+ GitHub has some pretty good
98
+ [general documentation](http://help.github.com/) on using
99
+ their site. They also have documentation on
100
+ [creating pull requests](http://help.github.com/send-pull-requests/).
101
+
102
+ In general, after pushing your topic branch up to your
103
+ repository on GitHub, you can switch to the branch in the
104
+ GitHub UI and click "Pull Request" towards the top of the page
105
+ in order to open a pull request.
106
+
107
+
108
+ 3. Update the related GitHub issue.
109
+
110
+ If there is a GitHub issue associated with the change you
111
+ submitted, then you should update the ticket to include the
112
+ location of your branch, along with any other commentary you
113
+ may wish to make.
114
+
115
+ ## Dependencies
116
+
117
+ The testing and development tools have a bunch of dependencies,
118
+ all managed by [bundler](http://bundler.io/) according to the
119
+ [Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions).
120
+
121
+ By default the tests use a baseline version of Puppet.
122
+
123
+ If you have Ruby 2.x or want a specific version of Puppet,
124
+ you must set an environment variable such as:
125
+
126
+ ```sh
127
+ export PUPPET_VERSION="~> 5.5.6"
128
+ ```
129
+
130
+ You can install all needed gems for spec tests into the modules directory by
131
+ running:
132
+
133
+ ```sh
134
+ bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)"
135
+ ```
136
+
137
+ If you also want to run acceptance tests:
138
+
139
+ ```sh
140
+ bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"
141
+ ```
142
+
143
+ Our all in one solution if you don't know if you need to install or update gems:
144
+
145
+ ```sh
146
+ bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean
147
+ ```
148
+
149
+ As an alternative to the `--jobs "$(nproc)` parameter, you can set an
150
+ environment variable:
151
+
152
+ ```sh
153
+ BUNDLE_JOBS="$(nproc)"
154
+ ```
155
+
156
+ ### Note for OS X users
157
+
158
+ `nproc` isn't a valid command under OS x. As an alternative, you can do:
159
+
160
+ ```sh
161
+ --jobs "$(sysctl -n hw.ncpu)"
162
+ ```
163
+
164
+ ## The test matrix
165
+
166
+ ### Syntax and style
167
+
168
+ The test suite will run [Puppet Lint](http://puppet-lint.com/) and
169
+ [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
170
+ check various syntax and style things. You can run these locally with:
171
+
172
+ ```sh
173
+ bundle exec rake lint
174
+ bundle exec rake validate
175
+ ```
176
+
177
+ It will also run some [Rubocop](http://batsov.com/rubocop/) tests
178
+ against it. You can run those locally ahead of time with:
179
+
180
+ ```sh
181
+ bundle exec rake rubocop
182
+ ```
183
+
184
+ ### Running the unit tests
185
+
186
+ The unit test suite covers most of the code, as mentioned above please
187
+ add tests if you're adding new functionality. If you've not used
188
+ [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask
189
+ about how best to test your new feature.
190
+
191
+ To run the linter, the syntax checker and the unit tests:
192
+
193
+ ```sh
194
+ bundle exec rake test
195
+ ```
196
+
197
+ To run your all the unit tests
198
+
199
+ ```sh
200
+ bundle exec rake spec
201
+ ```
202
+
203
+ To run a specific spec test set the `SPEC` variable:
204
+
205
+ ```sh
206
+ bundle exec rake spec SPEC=spec/foo_spec.rb
207
+ ```
208
+
209
+ #### Unit tests in docker
210
+
211
+ Some people don't want to run the dependencies locally or don't want to install
212
+ ruby. We ship a Dockerfile that enables you to run all unit tests and linting.
213
+ You only need to run:
214
+
215
+ ```sh
216
+ docker build .
217
+ ```
218
+
219
+ Please ensure that a docker daemon is running and that your user has the
220
+ permission to talk to it. You can specify a remote docker host by setting the
221
+ `DOCKER_HOST` environment variable. it will copy the content of the module into
222
+ the docker image. So it will not work if a Gemfile.lock exists.
223
+
224
+ ### Integration tests
225
+
226
+ The unit tests just check the code runs, not that it does exactly what
227
+ we want on a real machine. For that we're using
228
+ [beaker](https://github.com/puppetlabs/beaker).
229
+
230
+ This fires up a new virtual machine (using vagrant) and runs a series of
231
+ simple tests against it after applying the module. You can run this
232
+ with:
233
+
234
+ ```sh
235
+ BEAKER_setfile=debian10-x64 bundle exec rake beaker
236
+ ```
237
+
238
+ You can replace the string `debian10` with any common operating system.
239
+ The following strings are known to work:
240
+
241
+ * ubuntu1604
242
+ * ubuntu1804
243
+ * ubuntu2004
244
+ * debian9
245
+ * debian10
246
+ * centos7
247
+ * centos8
248
+
249
+ For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests).
250
+
251
+ The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb)
252
+ repository.
@@ -0,0 +1,26 @@
1
+ <!--
2
+ Thank you for contributing to this project!
3
+
4
+ - This project has a Contributor Code of Conduct: https://voxpupuli.org/coc/
5
+ - Please check that here is no existing issue or PR that addresses your problem.
6
+ - Please fill the following form to enable us to help you.
7
+ - Our vulnerabilities reporting process is at https://voxpupuli.org/security/
8
+
9
+ -->
10
+
11
+ ## Affected Puppet, Ruby, OS and module versions/distributions
12
+
13
+ - Puppet:
14
+ - Ruby:
15
+ - Distribution:
16
+ - Module version:
17
+
18
+ ## How to reproduce (e.g Puppet code you use)
19
+
20
+ ## What are you seeing
21
+
22
+ ## What behaviour did you expect instead
23
+
24
+ ## Output log
25
+
26
+ ## Any additional information you'd like to impart
@@ -0,0 +1,20 @@
1
+ <!--
2
+ Thank you for contributing to this project!
3
+
4
+ - This project has a Contributor Code of Conduct: https://voxpupuli.org/coc/
5
+ - Please check that here is no existing issue or PR that addresses your problem.
6
+ - Our vulnerabilities reporting process is at https://voxpupuli.org/security/
7
+
8
+ -->
9
+ #### Pull Request (PR) description
10
+ <!--
11
+ Replace this comment with a description of your pull request.
12
+ -->
13
+
14
+ #### This Pull Request (PR) fixes the following issues
15
+ <!--
16
+ Replace this comment with the list of issues or n/a.
17
+ Use format:
18
+ Fixes #123
19
+ Fixes #124
20
+ -->
@@ -0,0 +1,3 @@
1
+ # Vox Pupuli Security Policy
2
+
3
+ Our vulnerabilities reporting process is at https://voxpupuli.org/security/
@@ -0,0 +1,31 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ if: github.repository_owner == 'voxpupuli'
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Install Ruby 3.0
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: '3.0'
18
+ bundler: 'none'
19
+ - name: Build gem
20
+ run: gem build *.gemspec
21
+ - name: Publish gem to rubygems.org
22
+ run: gem push *.gem
23
+ env:
24
+ GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
25
+ - name: Setup GitHub packages access
26
+ run: |
27
+ mkdir -p ~/.gem
28
+ echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
29
+ chmod 0600 ~/.gem/credentials
30
+ - name: Publish gem to GitHub packages
31
+ run: gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
@@ -0,0 +1,35 @@
1
+ name: Test
2
+
3
+ on:
4
+ - pull_request
5
+ - push
6
+
7
+ env:
8
+ BUNDLE_WITHOUT: release
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ include:
17
+ - ruby: "2.4"
18
+ - ruby: "2.5"
19
+ - ruby: "2.6"
20
+ - ruby: "2.7"
21
+ - ruby: "3.0"
22
+ coverage: "yes"
23
+ env:
24
+ COVERAGE: ${{ matrix.coverage }}
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+ - name: Install Ruby ${{ matrix.ruby }}
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ bundler-cache: true
32
+ - name: Run tests
33
+ run: bundle exec rake spec
34
+ - name: Verify gem builds
35
+ run: gem build *.gemspec
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /.bundle/
2
+ /vendor/gems/
3
+ /Gemfile.lock
4
+ vendor/bundle
5
+ .vendor/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_gem:
2
+ voxpupuli-test: rubocop.yml
3
+
4
+ Style/FileName:
5
+ Exclude:
6
+ - "*.gemspec"
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [1.0.0](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/tree/1.0.0) (2021-10-28)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/compare/5a7c1367870df1f8cd84621e74f50cc850c66311...1.0.0)
8
+
9
+ **Merged pull requests:**
10
+
11
+ - Prepare for 1.0.0 - General Availability [\#1](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/pull/1) ([smortex](https://github.com/smortex))
12
+
13
+
14
+
15
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
@@ -0,0 +1,77 @@
1
+ # Contributor Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
26
+ * Trolling, insulting/derogatory comments, and personal or political attacks
27
+ * Public or private harassment
28
+ * Publishing others' private information, such as a physical or electronic
29
+ address, without explicit permission
30
+ * Other conduct which could reasonably be considered inappropriate in a
31
+ professional setting
32
+
33
+ ## Our Responsibilities
34
+
35
+ Project maintainers are responsible for clarifying the standards of acceptable
36
+ behavior and are expected to take appropriate and fair corrective action in
37
+ response to any instances of unacceptable behavior.
38
+
39
+ Project maintainers have the right and responsibility to remove, edit, or
40
+ reject comments, commits, code, wiki edits, issues, and other contributions
41
+ that are not aligned to this Code of Conduct, or to ban temporarily or
42
+ permanently any contributor for other behaviors that they deem inappropriate,
43
+ threatening, offensive, or harmful.
44
+
45
+ Our maintainers are elected on a yearly basis as the project management
46
+ committee. You can find an up to date list of those people [on our site][pmc]
47
+
48
+ ## Scope
49
+
50
+ This Code of Conduct applies both within project spaces and in public spaces
51
+ when an individual is representing the project or its community. Examples of
52
+ representing a project or community include using an official project e-mail
53
+ address, posting via an official social media account, or acting as an appointed
54
+ representative at an online or offline event. Representation of a project may be
55
+ further defined and clarified by project maintainers.
56
+
57
+ ## Enforcement
58
+
59
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
60
+ reported by contacting the project team at [pmc@voxpupuli.org](pmc@voxpupuli.org).
61
+ All complaints will be reviewed and investigated and will result in a response that
62
+ is deemed necessary and appropriate to the circumstances. The project team is
63
+ obligated to maintain confidentiality with regard to the reporter of an incident.
64
+ Further details of specific enforcement policies may be posted separately.
65
+
66
+ Project maintainers who do not follow or enforce the Code of Conduct in good
67
+ faith may face temporary or permanent repercussions as determined by other
68
+ members of the project's leadership.
69
+
70
+ ## Attribution
71
+
72
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
73
+ version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
74
+
75
+ [pmc]: https://voxpupuli.org/docs/#project-management-committee
76
+ [homepage]: http://contributor-covenant.org
77
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :release do
6
+ gem 'github_changelog_generator', require: false
7
+ end
8
+
9
+ group :coverage, optional: ENV['COVERAGE']!='yes' do
10
+ gem 'simplecov-console', :require => false
11
+ gem 'codecov', :require => false
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Romain Tartière
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # puppet-lint-lookup\_in\_parameter-check
2
+
3
+ [![License](https://img.shields.io/github/license/voxpupuli/puppet-lint-lookup_in_parameter-check.svg)](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/blob/master/LICENSE)
4
+ [![Test](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/actions/workflows/test.yml)
5
+ [![Release](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/actions/workflows/release.yml)
6
+ [![RubyGem Version](https://img.shields.io/gem/v/puppet-lint-lookup_in_parameter-check.svg)](https://rubygems.org/gems/puppet-lint-lookup_in_parameter-check)
7
+ [![RubyGem Downloads](https://img.shields.io/gem/dt/puppet-lint-lookup_in_parameter-check.svg)](https://rubygems.org/gems/puppet-lint-lookup_in_parameter-check)
8
+ [![codecov](https://codecov.io/gh/voxpupuli/puppet-lint-lookup_in_parameter-check/branch/master/graph/badge.svg)](https://codecov.io/gh/voxpupuli/puppet-lint-lookup_in_parameter-check)
9
+
10
+ A puppet-lint plugin to check for calls to `lookup` in parameters.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'puppet-lint-lookup_in_parameter-check'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle install
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install puppet-lint-lookup_in_parameter-check
27
+
28
+ ## Rationale
29
+
30
+ Usage of `lookup` for fetching the default value of a parameter is a smell that prevent a strict usage of the roles and profiles pattern.
31
+
32
+ Consider a module which has a main class (`acme`) class that install the software and a defined type (`acme::module`) that extend the configuration:
33
+
34
+ ```yaml
35
+ ---
36
+ acme::config_dir: '/etc/acme'
37
+ ```
38
+
39
+ ```puppet
40
+ # manifests/init.pp
41
+ class acme (
42
+ Stdlib::Absolutepath $config_dir,
43
+ ) {
44
+ file { $config_dir:
45
+ ensure => directory,
46
+ }
47
+
48
+ file { "${config_dir}/modules":
49
+ ensure => directory,
50
+ }
51
+ }
52
+
53
+ # manifests/module.pp
54
+ define acme::module (
55
+ String[1] $config,
56
+ Stdlib::Absolutepath $config_dir = lookup('acme::config_dir'),
57
+ ) {
58
+ file { "${config_dir}/modules/${title}":
59
+ ensure => file,
60
+ content => $config,
61
+ }
62
+ }
63
+ ```
64
+
65
+ When configuring this module with a custom `config_dir`, one has to explicitely set this parameter all the time:
66
+
67
+ ```puppet
68
+ class { 'acme':
69
+ config_dir => '/opt/acme',
70
+ }
71
+
72
+ acme::module { 'foo':
73
+ config => $foo_config,
74
+ config_dir => '/opt/acme', # If not set, `/etc/acme` from hiera would be used
75
+ }
76
+ ```
77
+
78
+ A better way is to include the main class from the defined class and use the variable from the main class like so:
79
+
80
+ ```puppet
81
+ # manifests/module.pp
82
+ define acme::module (
83
+ String[1] $config,
84
+ ) {
85
+ include acme
86
+
87
+ file { "${acme::config_dir}/modules/${title}":
88
+ ensure => file,
89
+ content => $config,
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## Development
95
+
96
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
97
+
98
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
99
+
100
+ ## Contributing
101
+
102
+ Bug reports and pull requests are welcome on GitHub at https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/blob/main/CODE_OF_CONDUCT.md).
103
+
104
+ ## License
105
+
106
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
107
+
108
+ ## Code of Conduct
109
+
110
+ Everyone interacting in the puppet-lint-lookup\_in\_parameter-check project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task default: :spec
6
+
7
+ begin
8
+ require 'rubygems'
9
+ require 'github_changelog_generator/task'
10
+
11
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
12
+ config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
13
+ config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog modulesync}
14
+ config.user = 'voxpupuli'
15
+ config.project = 'puppet-lint-lookup_in_parameter-check'
16
+ config.future_release = Gem::Specification.load("#{config.project}.gemspec").version
17
+ end
18
+ rescue LoadError
19
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'puppet/lint/lookup_in_parameter/check'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ PuppetLint.new_check(:lookup_in_parameter) do
4
+ def check
5
+ active = false
6
+ tokens.each do |token|
7
+ case token.type
8
+ when :CLASS, :DEFINE
9
+ active = 0 if token.next_code_token.type == :NAME && token.next_code_token.next_code_token.type == :LPAREN
10
+ when :LPAREN
11
+ active += 1 if active
12
+ when :RPAREN
13
+ if active
14
+ active -= 1
15
+ active = false if active.zero?
16
+ end
17
+ when :FUNCTION_NAME
18
+ next unless active
19
+ next unless token.value == 'lookup'
20
+ notify :warning, {
21
+ message: 'lookup used to set the default value of a parameter',
22
+ line: token.line,
23
+ column: token.column,
24
+ token: token,
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'puppet-lint-lookup_in_parameter-check'
5
+ spec.version = '1.0.0'
6
+ spec.authors = ['Romain Tartière']
7
+ spec.email = ['romain@blogreen.org']
8
+
9
+ spec.summary = 'Check lookup is not used in parameters'
10
+ spec.homepage = 'https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check'
11
+ spec.license = 'MIT'
12
+ spec.required_ruby_version = '>= 2.4.0'
13
+
14
+ spec.metadata['homepage_uri'] = spec.homepage
15
+ spec.metadata['source_code_uri'] = spec.homepage
16
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_dependency 'puppet-lint', '~> 2.0'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'rspec-collection_matchers'
31
+ spec.add_development_dependency 'rspec-its'
32
+ spec.add_development_dependency 'rubocop'
33
+ spec.add_development_dependency 'voxpupuli-test'
34
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-lint-lookup_in_parameter-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Romain Tartière
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-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: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '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: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
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: rubocop
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: voxpupuli-test
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:
112
+ email:
113
+ - romain@blogreen.org
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".github/CONTRIBUTING.md"
119
+ - ".github/ISSUE_TEMPLATE.md"
120
+ - ".github/PULL_REQUEST_TEMPLATE.md"
121
+ - ".github/SECURITY.md"
122
+ - ".github/workflows/release.yml"
123
+ - ".github/workflows/test.yml"
124
+ - ".gitignore"
125
+ - ".rspec"
126
+ - ".rubocop.yml"
127
+ - CHANGELOG.md
128
+ - CODE_OF_CONDUCT.md
129
+ - Gemfile
130
+ - LICENSE.txt
131
+ - README.md
132
+ - Rakefile
133
+ - bin/console
134
+ - bin/setup
135
+ - lib/puppet-lint/plugins/lookup_in_parameter.rb
136
+ - puppet-lint-lookup_in_parameter-check.gemspec
137
+ homepage: https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check
138
+ licenses:
139
+ - MIT
140
+ metadata:
141
+ homepage_uri: https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check
142
+ source_code_uri: https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check
143
+ changelog_uri: https://github.com/voxpupuli/puppet-lint-lookup_in_parameter-check/blob/main/CHANGELOG.md
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.4.0
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubygems_version: 3.2.22
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Check lookup is not used in parameters
163
+ test_files: []