puppet-lint-no_cron_resources-check 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: 6c43488e2ec3edccca54352ce9da73580a48cb0a
4
+ data.tar.gz: b5145bbe443e9af29116e647ee55d5b9d857ba4e
5
+ SHA512:
6
+ metadata.gz: d6809a9bb28150fa192ea3b305e71b71200fa95f20b5e2c8bfb603c1c5bdeeefbfae6f0f0dfc90cb14437041b446e46bff63523311293744f5eac127c25ce21a
7
+ data.tar.gz: 7317a4042fde5935fd95e29b1319ec023002c53d8a0ae369d90d886ba7729f94cffcf4a48d00effa9d0a9bc42033eeb506597f6eddc7a159f8bbefd4456cc8ba
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,51 @@
1
+ # puppet-lint no_cron_resources check #
2
+
3
+ Extends puppet-lint to ensure no cron resources are contained in
4
+ the catalog.
5
+
6
+ [![Build Status](https://travis-ci.org/deanwilson/puppet-lint-no_cron_resources-check.svg?branch=master)](https://travis-ci.org/deanwilson/puppet-lint-no_cron_resources-check)
7
+
8
+ Sometimes there are certain `puppet` resource types that you don't want
9
+ to include in your code base. This could be a fragile one like `cron`,
10
+ an easy to abuse one like `augeas` or one you just dislike the name
11
+ of, I'm looking at you `computer`. This `puppet-lint` check will
12
+ display a warning each time it finds a usage of that resource, in this
13
+ case `cron`.
14
+
15
+ ## Installation ##
16
+
17
+ To use this plugin add the following line to your Gemfile
18
+
19
+ gem 'puppet-lint-no_cron_resources-check'
20
+
21
+ and then run `bundle install`
22
+
23
+ ## Usage ##
24
+
25
+ This plugin provides a new check to `puppet-lint` that warns if it finds
26
+ a `cron` resource.
27
+
28
+ cron resources should not be used
29
+
30
+ ## Customisation ##
31
+
32
+ It may be that you love `cron` resources but hate the idea of another
33
+ specific type appearing in your code. To modify this `puppet-line` check
34
+ to detect another type you only need to run the following commands:
35
+
36
+ # grab this repo
37
+ git clone https://github.com/deanwilson/puppet-lint-no_cron_resources-check.git
38
+
39
+ # make a new copy of the code and cd to it
40
+ cp -a puppet-lint-no_cron_resources-check puppet-lint-no_augeas_resources-check
41
+ cd puppet-lint-no_augeas_resources-check/
42
+
43
+ # rename the files and replace the resource type.
44
+ find | grep -v .git | xargs -n 1 rename cron augeas
45
+ find -type f | grep -v .git | xargs sed -i -e 's/cron/augeas/g'
46
+
47
+ # and rerun the tests
48
+ bundle exec rake spec
49
+
50
+ ### Author ###
51
+ [Dean Wilson](http://www.unixdaemon.net)
@@ -0,0 +1,17 @@
1
+ PuppetLint.new_check(:no_cron_resources) do
2
+
3
+ def check
4
+ resource_indexes.each do |resource|
5
+ if resource[:type].value == 'cron'
6
+
7
+ notify :warning, {
8
+ :message => 'cron resources should not be used',
9
+ :line => resource[:type].line,
10
+ :column => resource[:type].column,
11
+ }
12
+
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'no_cron_resources' do
4
+ let(:msg) { 'cron resources should not be used' }
5
+
6
+ context 'catalogfile with out cron resources' do
7
+ let(:code) do
8
+ <<-EOS
9
+ class file_resource {
10
+ file { '/tmp/my-file':
11
+ mode => '0600',
12
+ }
13
+ }
14
+ EOS
15
+ end
16
+
17
+ it 'should not detect any problems' do
18
+ expect(problems).to have(0).problems
19
+ end
20
+ end
21
+
22
+ context 'catalogfile with cron resources' do
23
+ let(:code) do
24
+ <<-EOS
25
+ class cron_resource {
26
+ cron { 'logrotate':
27
+ command => '/usr/sbin/logrotate',
28
+ user => root,
29
+ hour => 2,
30
+ minute => 0,
31
+ }
32
+ }
33
+ EOS
34
+ end
35
+
36
+ it 'should detect a single problem' do
37
+ expect(problems).to have(1).problem
38
+ end
39
+
40
+ it 'should create a warning' do
41
+ expect(problems).to contain_warning(msg).on_line(2).in_column(11)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ require 'puppet-lint'
2
+
3
+ PuppetLint::Plugins.load_spec_helper
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-lint-no_cron_resources-check
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: 2016-01-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: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.36.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.36.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
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
+ description: |2
98
+ Extends puppet-lint to ensure no cron resources are contained in the catalog.
99
+ email: dean.wilson@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - LICENSE
105
+ - README.md
106
+ - lib/puppet-lint/plugins/no_cron_resources.rb
107
+ - spec/puppet-lint/plugins/puppet-lint-no_cron_resources_spec.rb
108
+ - spec/spec_helper.rb
109
+ homepage: https://github.com/deanwilson/no_cron_resources-check
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.8
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: puppet-lint no_cron_resources check
133
+ test_files:
134
+ - spec/spec_helper.rb
135
+ - spec/puppet-lint/plugins/puppet-lint-no_cron_resources_spec.rb
136
+ has_rdoc: