puppet-syntax 2.4.3 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c2d5ed9b5ecdfbad2253a6e53cb64577e59672e580aef20ba577122bfd84b46
4
- data.tar.gz: 77e8fa3182add57817b9a3b6a3dc2f1b26dd5497fbec13197072231067f0610f
3
+ metadata.gz: db77920a61d0b8ea3ccbc521c7dad372f382fe897f7cabb6532acb7a154ae49a
4
+ data.tar.gz: c61d81fc4bb5eb0a655c951c849d0124e3123253ca2fa5de2ecabbe1b524f9e7
5
5
  SHA512:
6
- metadata.gz: ae928b3759c9a417561ec58a6ed851df0cd835473d554c1a3ea578d230cfa8514155351757fc52e6e787fb41762f91ac69a5c5a1bfe767b6fc43d4154ae07920
7
- data.tar.gz: df4b04fdf1a0a6cbd26e3f847336e0a28c7f11fdeccb1040f08c011f4663eb50c477fb3037d187b109e4375993e47bd8d53030e48c3f175117fdf61649a8847f
6
+ metadata.gz: d51df8b8a2975e90d44fa9fad4892609b331a95bd459e226af0a7d80589458e059e06149da6412aae6d32de0e0ab058a0517e552be3ab9edf07670c712c3bba7
7
+ data.tar.gz: 8aa88875e46d83c30eac88b28219f1daef4e905782c6997cb0fe8973c84bbbaec6d891d171ecd66930e1e6ab4a9e7154db63a87f4eef99317f000e7ffcf3667c
data/.gitignore CHANGED
@@ -16,4 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  vendor/
19
- .idea/
19
+ .idea/
20
+ .vendor/
@@ -1,16 +1,19 @@
1
1
  ---
2
+ dist: bionic
2
3
  language: ruby
3
4
  # Workaround https://github.com/bundler/bundler/issues/3558
4
5
  before_install: gem install bundler
5
- install: bundle install --jobs 4 --retry 2 --without development
6
+ install: bundle install --jobs 4 --retry 2 --without development release
6
7
  script: bundle exec rake
7
8
  rvm:
8
9
  - 2.4.4
9
10
  - 2.5.1
11
+ - 2.6.5
10
12
  env:
11
13
  - PUPPET_VERSION="~> 5.5.10"
12
14
  - PUPPET_VERSION="~> 6.1.0"
13
15
  - PUPPET_VERSION="~> 6.2.0"
16
+ - PUPPET_VERSION="~> 6.5.0"
14
17
  - PUPPET_VERSION=">= 0"
15
18
  - PUPPET_VERSION="git://github.com/puppetlabs/puppet.git#master"
16
19
  matrix:
@@ -28,3 +31,10 @@ deploy:
28
31
  tags: true
29
32
  all_branches: true
30
33
  repo: voxpupuli/puppet-syntax
34
+ notifications:
35
+ email: false
36
+ irc:
37
+ on_success: always
38
+ on_failure: always
39
+ channels:
40
+ - "chat.freenode.org#voxpupuli-notifications"
@@ -2,6 +2,65 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [v3.0.1](https://github.com/voxpupuli/puppet-syntax/tree/v3.0.1) (2020-05-27)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v3.0.0...v3.0.1)
8
+
9
+ **Merged pull requests:**
10
+
11
+ - Avoid failure on schedule metaparameter warning [\#122](https://github.com/voxpupuli/puppet-syntax/pull/122) ([ffapitalle](https://github.com/ffapitalle))
12
+
13
+ ## [v3.0.0](https://github.com/voxpupuli/puppet-syntax/tree/v3.0.0) (2020-05-09)
14
+
15
+ [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.6.1...v3.0.0)
16
+
17
+ **Breaking changes:**
18
+
19
+ - Drop legacy code to support Puppet \< 5 and Ruby \< 2.4 [\#120](https://github.com/voxpupuli/puppet-syntax/pull/120) ([ekohl](https://github.com/ekohl))
20
+
21
+ **Implemented enhancements:**
22
+
23
+ - Migrate Changelog to GCG [\#93](https://github.com/voxpupuli/puppet-syntax/issues/93)
24
+
25
+ **Merged pull requests:**
26
+
27
+ - cleanup README.md / fix markdown linter warnings [\#119](https://github.com/voxpupuli/puppet-syntax/pull/119) ([bastelfreak](https://github.com/bastelfreak))
28
+
29
+ ## [v2.6.1](https://github.com/voxpupuli/puppet-syntax/tree/v2.6.1) (2020-01-11)
30
+
31
+ [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.6.0...v2.6.1)
32
+
33
+ **Fixed bugs:**
34
+
35
+ - Add `puppet` gem as runtime dependency [\#116](https://github.com/voxpupuli/puppet-syntax/pull/116) ([bastelfreak](https://github.com/bastelfreak))
36
+
37
+ **Merged pull requests:**
38
+
39
+ - traivs: run tests on Ubuntu 18.04 [\#117](https://github.com/voxpupuli/puppet-syntax/pull/117) ([bastelfreak](https://github.com/bastelfreak))
40
+ - travis: enable irc / disable email notifications [\#114](https://github.com/voxpupuli/puppet-syntax/pull/114) ([bastelfreak](https://github.com/bastelfreak))
41
+
42
+ ## [v2.6.0](https://github.com/voxpupuli/puppet-syntax/tree/v2.6.0) (2019-10-05)
43
+
44
+ [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.5.0...v2.6.0)
45
+
46
+ **Implemented enhancements:**
47
+
48
+ - add support for validating puppet plans \(fixes \#95, fixes \#96\) [\#97](https://github.com/voxpupuli/puppet-syntax/pull/97) ([slauger](https://github.com/slauger))
49
+ - Allow specifying file paths for manifests and templates too [\#87](https://github.com/voxpupuli/puppet-syntax/pull/87) ([lavagetto](https://github.com/lavagetto))
50
+
51
+ **Merged pull requests:**
52
+
53
+ - Test on ruby 2.6 [\#111](https://github.com/voxpupuli/puppet-syntax/pull/111) ([alexjfisher](https://github.com/alexjfisher))
54
+ - Adding KMS tags to allowed EYAML methods [\#105](https://github.com/voxpupuli/puppet-syntax/pull/105) ([craigwatson](https://github.com/craigwatson))
55
+
56
+ ## [v2.5.0](https://github.com/voxpupuli/puppet-syntax/tree/v2.5.0) (2019-07-07)
57
+
58
+ [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.4.3...v2.5.0)
59
+
60
+ **Implemented enhancements:**
61
+
62
+ - Support puppet 6.5 [\#106](https://github.com/voxpupuli/puppet-syntax/pull/106) ([alexjfisher](https://github.com/alexjfisher))
63
+
5
64
  ## [v2.4.3](https://github.com/voxpupuli/puppet-syntax/tree/v2.4.3) (2019-02-09)
6
65
 
7
66
  [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.4.2...v2.4.3)
data/Gemfile CHANGED
@@ -18,15 +18,13 @@ end
18
18
  gemspec
19
19
 
20
20
  # Override gemspec for CI matrix builds.
21
- gem 'puppet', *location_for(ENV['PUPPET_VERSION'] || '>2.7.0')
22
-
23
- # older version required for ruby 1.9 compat, as it is pulled in as dependency of puppet, this has to be carried by the module
24
- gem 'json_pure', '<= 2.0.1'
21
+ # But only if the environment variable is set
22
+ gem 'puppet', *location_for(ENV['PUPPET_VERSION'] || '>= 5') if ENV['PUPPET_VERSION']
25
23
 
26
24
  group :test do
27
25
  gem 'rspec'
28
26
  end
29
27
 
30
28
  group :release do
31
- gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' if RUBY_VERSION >= '2.2.2'
29
+ gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator'
32
30
  end
data/README.md CHANGED
@@ -4,36 +4,40 @@
4
4
 
5
5
  # Puppet::Syntax
6
6
 
7
- Puppet::Syntax checks for correct syntax in Puppet manifests, templates, and Hiera YAML.
7
+ Puppet::Syntax checks for correct syntax in Puppet manifests, templates, and
8
+ Hiera YAML.
8
9
 
9
10
  ## Version support
10
11
 
11
12
  Puppet::Syntax is supported with:
12
13
 
13
- - Puppet >= 2.7 that provides the `validate` face.
14
- - Ruby >= 1.8 with `erb` from Ruby stdlib.
14
+ - Puppet >= 5.0 that provides the `validate` face.
15
+ - Ruby >= 2.4
15
16
 
16
17
  For the specific versions that we test against, see the [TravisCI config](.travis.yml).
17
18
 
18
- If you're using `puppetlabs_spec_helper/rake_tasks` and getting unexpected non-zero exit codes, upgrade to [puppetlabs_spec_helper][psh] version 0.8.0 or greater. Versions of `puppetlabs_spec_helper` prior to 0.8.0 conflicted with Puppet::Syntax.
19
-
20
- [psh]: https://github.com/puppetlabs/puppetlabs_spec_helper
21
-
22
19
  ## Installation
23
20
 
24
- To install Puppet::Syntax, either add it to your module's Gemfile or install the gem manually.
21
+ To install Puppet::Syntax, either add it to your module's Gemfile or install
22
+ the gem manually.
25
23
 
26
24
  * To install with the Gemfile, add:
27
25
 
28
- gem 'puppet-syntax'
26
+ ```ruby
27
+ gem 'puppet-syntax'
28
+ ```
29
29
 
30
30
  And then execute:
31
31
 
32
- $ bundle install
32
+ ```sh
33
+ bundle install
34
+ ```
33
35
 
34
36
  * To install the gem yourself, run:
35
37
 
36
- $ gem install puppet-syntax
38
+ ```sh
39
+ gem install puppet-syntax
40
+ ```
37
41
 
38
42
  ## Configuration
39
43
 
@@ -41,70 +45,85 @@ To configure Puppet::Syntax, add any of the following settings to your `Rakefile
41
45
 
42
46
  * To exclude certain paths from the syntax checks, set:
43
47
 
44
- PuppetSyntax.exclude_paths = ["vendor/**/*"]
45
-
46
- * To use the Puppet 4 ("future") parser in Puppet 3.2 through 3.8, set:
47
-
48
- PuppetSyntax.future_parser = true
48
+ ```ruby
49
+ PuppetSyntax.exclude_paths = ["vendor/**/*"]
50
+ ```
49
51
 
50
52
  * To configure specific paths for the Hiera syntax check, specify `hieradata_paths`. This is useful if you use Hiera data inside your module.
51
53
 
52
- PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"]
53
-
54
- * To validate the syntax of code written for application orchestration, enable `app_management`:
54
+ ```ruby
55
+ PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"]
56
+ ```
55
57
 
56
- PuppetSyntax.app_management = true
58
+ * To configure specific paths for the Puppet syntax checks or for the templates checks, specify `manifests_paths` or `templates_paths` respectively. This is useful if you want to check specific paths only.
57
59
 
58
- The `app_management` setting is supported with Puppet 4.3 or greater and is off by default. In Puppet 5, app_management is always enabled.
60
+ ```ruby
61
+ PuppetSyntax.manifests_paths = ["**/environments/future/*.pp"]
62
+ PuppetSyntax.templates_paths = ["**/modules/**/templates/*.erb"]
63
+ ```
59
64
 
60
65
  * To ignore deprecation warnings, disable `fail_on_deprecation_notices`. By default, `puppet-syntax` fails if it encounters Puppet deprecation notices. If you are working with a legacy code base and want to ignore such non-fatal warnings, you might want to override the default behavior.
61
66
 
62
- PuppetSyntax.fail_on_deprecation_notices = false
67
+ ```ruby
68
+ PuppetSyntax.fail_on_deprecation_notices = false
69
+ ```
63
70
 
64
71
  * To enable a syntax check on Hiera keys, set:
65
72
 
66
- PuppetSyntax.check_hiera_keys = true
73
+ ```ruby
74
+ PuppetSyntax.check_hiera_keys = true
75
+ ```
67
76
 
68
- This reports common mistakes in key names in Hiera files, such as:
77
+ This reports common mistakes in key names in Hiera files, such as:
69
78
 
70
- - Leading `::` in keys, such as: `::notsotypical::warning2: true`.
71
- - Single colon scope separators, such as: `:picky::warning5: true`.
72
- - Invalid camel casing, such as: `noCamelCase::warning3: true`.
73
- - Use of hyphens, such as: `no-hyphens::warning4: true`.
79
+ * Leading `::` in keys, such as: `::notsotypical::warning2: true`.
80
+ * Single colon scope separators, such as: `:picky::warning5: true`.
81
+ * Invalid camel casing, such as: `noCamelCase::warning3: true`.
82
+ * Use of hyphens, such as: `no-hyphens::warning4: true`.
74
83
 
75
84
  ## Usage
76
85
 
77
86
  * To enable Puppet::Syntax, include the following in your module's `Rakefile`:
78
87
 
79
- require 'puppet-syntax/tasks/puppet-syntax'
88
+ ```ruby
89
+ require 'puppet-syntax/tasks/puppet-syntax'
90
+ ```
80
91
 
81
- For Continuous Integration, use Puppet::Syntax in conjunction with `puppet-lint` and spec tests. Add the following to your module's `Rakefile`:
92
+ For Continuous Integration, use Puppet::Syntax in conjunction with `puppet-lint`
93
+ and spec tests. Add the following to your module's `Rakefile`:
82
94
 
83
- task :test => [
84
- :syntax,
85
- :lint,
86
- :spec,
87
- ]
95
+ ```ruby
96
+ task :test => [
97
+ :syntax,
98
+ :lint,
99
+ :spec,
100
+ ]
101
+ ```
88
102
 
89
103
  * To test all manifests and templates, relative to the location of the `Rakefile`, run:
90
104
 
91
- $ bundle exec rake syntax
92
- ---> syntax:manifests
93
- ---> syntax:templates
94
- ---> syntax:hiera:yaml
105
+ ```
106
+ $ bundle exec rake syntax
107
+ ---> syntax:manifests
108
+ ---> syntax:templates
109
+ ---> syntax:hiera:yaml
110
+ ```
95
111
 
96
112
  * To return a non-zero exit code and an error message on any failures, run:
97
113
 
98
- $ bundle exec rake syntax
99
- ---> syntax:manifests
100
- rake aborted!
101
- Could not parse for environment production: Syntax error at end of file at demo.pp:2
102
- Tasks: TOP => syntax => syntax:manifests
103
- (See full trace by running task with --trace)
114
+ ```
115
+ $ bundle exec rake syntax
116
+ ---> syntax:manifests
117
+ rake aborted!
118
+ Could not parse for environment production: Syntax error at end of file at demo.pp:2
119
+ Tasks: TOP => syntax => syntax:manifests
120
+ (See full trace by running task with --trace)
121
+ ```
104
122
 
105
123
  ## Checks
106
124
 
107
- Puppet::Syntax makes the following checks in the directories and subdirectories of the module, relative to the location of the `Rakefile`.
125
+ Puppet::Syntax makes the following checks in the directories and subdirectories
126
+ of the module, relative to the location of the `Rakefile`.
108
127
 
109
128
  ### Hiera
110
129
 
@@ -130,7 +149,8 @@ Checks `.erb` files in the module for syntax errors.
130
149
 
131
150
  Checks `.epp` files in the module for syntax errors.
132
151
 
133
- EPP checks are supported in Puppet 4 or greater, or in Puppet 3 with the future parser enabled.
152
+ EPP checks are supported in Puppet 4 or greater, or in Puppet 3 with the future
153
+ parser enabled.
134
154
 
135
155
  ## Contributing
136
156
 
@@ -6,28 +6,28 @@ require "puppet/version"
6
6
 
7
7
  module PuppetSyntax
8
8
  @exclude_paths = []
9
- @future_parser = false
10
9
  @hieradata_paths = [
11
10
  "**/data/**/*.*{yaml,yml}",
12
11
  "hieradata/**/*.*{yaml,yml}",
13
12
  "hiera*.*{yaml,yml}"
14
13
  ]
14
+ @manifests_paths = [
15
+ '**/*.pp'
16
+ ]
17
+ @templates_paths = [
18
+ '**/templates/**/*.erb',
19
+ '**/templates/**/*.epp'
20
+ ]
15
21
  @fail_on_deprecation_notices = true
16
- @app_management = Puppet.version.to_i >= 5 ? true : false
17
22
  @check_hiera_keys = false
18
23
 
19
24
  class << self
20
25
  attr_accessor :exclude_paths,
21
- :future_parser,
22
26
  :hieradata_paths,
27
+ :manifests_paths,
28
+ :templates_paths,
23
29
  :fail_on_deprecation_notices,
24
30
  :epp_only,
25
31
  :check_hiera_keys
26
- attr_reader :app_management
27
-
28
- def app_management=(app_management)
29
- raise 'app_management cannot be disabled on Puppet 5 or higher' if Puppet.version.to_i >= 5 && !app_management
30
- @app_management = app_management
31
- end
32
32
  end
33
33
  end
@@ -56,7 +56,7 @@ module PuppetSyntax
56
56
  method = 'PKCS7'
57
57
  end
58
58
 
59
- return "has unknown eyaml method #{method}" unless ['PKCS7','GPG'].include? method
59
+ return "has unknown eyaml method #{method}" unless ['PKCS7','GPG','GKMS','KMS'].include? method
60
60
  return "has unpadded or truncated base64 data" unless base64.length % 4 == 0
61
61
 
62
62
  # Base64#decode64 will silently ignore characters outside the alphabet,
@@ -8,9 +8,7 @@ module PuppetSyntax
8
8
 
9
9
  output = []
10
10
 
11
- if Puppet::Test::TestHelper.respond_to?(:initialize) # 3.1+
12
- Puppet::Test::TestHelper.initialize
13
- end
11
+ Puppet::Test::TestHelper.initialize
14
12
  Puppet::Test::TestHelper.before_all_tests
15
13
  called_before_all_tests = true
16
14
 
@@ -21,9 +19,13 @@ module PuppetSyntax
21
19
  filelist.each do |puppet_file|
22
20
  Puppet::Test::TestHelper.before_each_test
23
21
  begin
24
- validate_manifest(puppet_file)
22
+ error = validate_manifest(puppet_file)
23
+ if error.is_a?(Hash) # Puppet 6.5.0 onwards
24
+ output << error.values.first unless error.empty?
25
+ end
25
26
  rescue SystemExit
26
27
  # Disregard exit(1) from face.
28
+ # This is how puppet < 6.5.0 `validate_manifest` worked.
27
29
  rescue => error
28
30
  output << error
29
31
  ensure
@@ -39,9 +41,9 @@ module PuppetSyntax
39
41
  e =~ /^You cannot collect( exported resources)? without storeconfigs being set/
40
42
  }
41
43
 
42
- # tag parameter in class raise warnings notice in output that prevent from succeed
44
+ # tag and schedule parameters in class raise warnings notice in output that prevent from succeed
43
45
  output.reject! { |e|
44
- e =~ /^tag is a metaparam; this value will inherit to all contained resources in the /
46
+ e =~ /^(tag|schedule) is a metaparam; this value will inherit to all contained resources in the /
45
47
  }
46
48
 
47
49
  deprecations = output.select { |e|
@@ -58,8 +60,7 @@ module PuppetSyntax
58
60
 
59
61
  private
60
62
  def validate_manifest(file)
61
- Puppet[:parser] = 'future' if PuppetSyntax.future_parser and Puppet.version.to_i < 4
62
- Puppet[:app_management] = true if PuppetSyntax.app_management && (Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0 && Puppet.version.to_i < 5)
63
+ Puppet[:tasks] = true if Puppet::Util::Package.versioncmp(Puppet.version, '5.4.0') >= 0 and file.match(/.*plans\/.*\.pp$/)
63
64
  Puppet::Face[:parser, :current].validate(file)
64
65
  end
65
66
  end
@@ -13,11 +13,11 @@ module PuppetSyntax
13
13
  end
14
14
 
15
15
  def filelist_manifests
16
- filelist("**/*.pp")
16
+ filelist(PuppetSyntax.manifests_paths)
17
17
  end
18
18
 
19
19
  def filelist_templates
20
- filelist(["**/templates/**/*.erb", "**/templates/**/*.epp"])
20
+ filelist(PuppetSyntax.templates_paths)
21
21
  end
22
22
 
23
23
  def filelist_hiera_yaml
@@ -27,42 +27,14 @@ module PuppetSyntax
27
27
  def initialize(*args)
28
28
  desc 'Syntax check Puppet manifests and templates'
29
29
  task :syntax => [
30
- 'syntax:check_puppetlabs_spec_helper',
31
30
  'syntax:manifests',
32
31
  'syntax:templates',
33
32
  'syntax:hiera',
34
33
  ]
35
34
 
36
35
  namespace :syntax do
37
- task :check_puppetlabs_spec_helper do
38
- psh_present = task(:syntax).actions.any? { |a|
39
- a.inspect.match(/puppetlabs_spec_helper\/rake_tasks\.rb:\d+/)
40
- }
41
-
42
- if psh_present
43
- $stderr.puts <<-EOS
44
- [WARNING] A conflicting :syntax rake task has been defined by
45
- puppetlabs_spec_helper/rake_tasks. You should either disable this or upgrade
46
- to puppetlabs_spec_helper >= 0.8.0 which now uses puppet-syntax.
47
- EOS
48
- end
49
- end
50
-
51
36
  desc 'Syntax check Puppet manifests'
52
37
  task :manifests do |t|
53
- if Puppet.version.to_i >= 4 and PuppetSyntax.future_parser
54
- $stderr.puts <<-EOS
55
- [INFO] Puppet 4 has been detected and `future_parser` has been set to
56
- 'true'. The `future_parser setting will be ignored.
57
- EOS
58
- end
59
- if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') < 0 and PuppetSyntax.app_management
60
- $stderr.puts <<-EOS
61
- [WARNING] Puppet `app_management` has been detected but the Puppet
62
- version is less then 4.3. The `app_management` setting will be ignored.
63
- EOS
64
- end
65
-
66
38
  $stderr.puts "---> #{t.name}"
67
39
 
68
40
  c = PuppetSyntax::Manifests.new
@@ -27,10 +27,6 @@ module PuppetSyntax
27
27
  end
28
28
 
29
29
  def validate_epp(filename)
30
- if Puppet.version.to_f < 3.7
31
- raise "Cannot validate EPP without Puppet 4 or future parser (3.7+)"
32
- end
33
-
34
30
  require 'puppet/pops'
35
31
  errors = []
36
32
  begin
@@ -1,3 +1,3 @@
1
1
  module PuppetSyntax
2
- VERSION = '2.4.3'
2
+ VERSION = '3.0.1'
3
3
  end
@@ -18,7 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.required_ruby_version = ">= 2.4"
22
+
21
23
  spec.add_dependency "rake"
24
+ spec.add_dependency "puppet", ">= 5"
22
25
 
23
26
  spec.add_development_dependency "pry"
24
27
  spec.add_development_dependency "rb-readline"
@@ -0,0 +1,5 @@
1
+ class schedule_parameter_test ($schedule=undef){
2
+ notify { 'schedule_should pass':
3
+ message => 'with flying colours',
4
+ }
5
+ }
@@ -24,19 +24,21 @@ describe PuppetSyntax::Manifests do
24
24
  expect(has_errors).to eq(false)
25
25
  end
26
26
 
27
+ it 'should return nothing from a valid file with a class using schedule parameter' do
28
+ files = fixture_manifests('schedule_notice.pp')
29
+ output, has_errors = subject.check(files)
30
+
31
+ expect(output).to eq([])
32
+ expect(has_errors).to eq(false)
33
+ end
34
+
27
35
  it 'should return an error from an invalid file' do
28
36
  files = fixture_manifests('fail_error.pp')
29
37
  output, has_errors = subject.check(files)
30
38
 
31
- if Puppet.version.to_i >= 4
32
- expect(output.size).to eq(3)
33
- expect(output[2]).to match(/2 errors. Giving up/)
34
- expect(has_errors).to eq(true)
35
- else
36
- expect(output.size).to eq(1)
37
- expect(output[0]).to match(/Syntax error at .*:3$/)
38
- expect(has_errors).to eq(true)
39
- end
39
+ expect(output.size).to eq(3)
40
+ expect(output[2]).to match(/2 errors. Giving up/)
41
+ expect(has_errors).to eq(true)
40
42
  end
41
43
 
42
44
  it 'should return a warning from an invalid file' do
@@ -72,181 +74,22 @@ describe PuppetSyntax::Manifests do
72
74
  output, has_errors = subject.check(files)
73
75
 
74
76
  expect(has_errors).to eq(true)
75
- if Puppet.version.to_i >= 4
76
- expect(output.size).to eq(5)
77
- expect(output[0]).to match(/This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect \(file: \S*\/fail_error.pp, line: 2, column: 32\)$/)
78
- expect(output[1]).to match(/This Name has no effect. A value was produced and then forgotten \(one or more preceding expressions may have the wrong form\) \(file: \S*\/fail_error.pp, line: 2, column: 3\)$/)
79
- expect(output[2]).to match('2 errors. Giving up')
80
- expect(output[3]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
81
- expect(output[4]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
82
- else
83
- expect(output.size).to eq(3)
84
- expect(output[0]).to match(/Syntax error at '\}' .*:3$/)
85
- expect(output[1]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
86
- expect(output[2]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
87
- end
77
+ expect(output.size).to eq(5)
78
+ expect(output[0]).to match(/This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect \(file: \S*\/fail_error.pp, line: 2, column: 32\)$/)
79
+ expect(output[1]).to match(/This Name has no effect. A value was produced and then forgotten \(one or more preceding expressions may have the wrong form\) \(file: \S*\/fail_error.pp, line: 2, column: 3\)$/)
80
+ expect(output[2]).to match('2 errors. Giving up')
81
+ expect(output[3]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
82
+ expect(output[4]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
88
83
  end
89
84
 
90
85
  describe 'deprecation notices' do
91
- case Puppet.version.to_f
92
- when 4.0..4.99
93
- context 'on puppet 4.0.0 and above' do
94
- it 'should instead be failures' do
95
- files = fixture_manifests('deprecation_notice.pp')
96
- output, has_errors = subject.check(files)
97
-
98
- expect(has_errors).to eq(true)
99
- expect(output.size).to eq(1)
100
- expect(output[0]).to match (/Node inheritance is not supported in Puppet >= 4.0.0/)
101
- end
102
- end
103
- when 3.7, 3.8
104
- context 'on puppet 3.7 and 3.8' do
105
- it 'should return deprecation notices as warnings' do
106
- files = fixture_manifests('deprecation_notice.pp')
107
- output, has_errors = subject.check(files)
108
-
109
- expect(has_errors).to eq(false)
110
- expect(output.size).to eq(2)
111
- expect(output[0]).to match(/The use of 'import' is deprecated/)
112
- expect(output[1]).to match(/Deprecation notice:/)
113
- end
114
- end
115
- when 3.5, 3.6
116
- context 'on puppet 3.5 and 3.6' do
117
- it 'should return deprecation notices as warnings' do
118
- files = fixture_manifests('deprecation_notice.pp')
119
- output, has_errors = subject.check(files)
120
-
121
- expect(has_errors).to eq(false)
122
- expect(output.size).to eq(1)
123
- expect(output[0]).to match(/The use of 'import' is deprecated/)
124
- end
125
- end
126
- when 3.0..3.4
127
- context 'on puppet 3.0 to 3.4' do
128
- it 'should not print deprecation notices' do
129
- files = fixture_manifests('deprecation_notice.pp')
130
- output, has_errors = subject.check(files)
131
-
132
- expect(output).to eq([])
133
- expect(has_errors).to eq(false)
134
- end
135
- end
136
- end
137
- end
138
-
139
- describe 'app_management' do
140
- after do
141
- PuppetSyntax.app_management = false if Puppet.version.to_i < 5
142
- end
86
+ it 'should instead be failures' do
87
+ files = fixture_manifests('deprecation_notice.pp')
88
+ output, has_errors = subject.check(files)
143
89
 
144
- context 'app_management = false (default)', :if => (Puppet.version.to_i < 5) do
145
- it 'should fail to parse an application manifest' do
146
-
147
- files = fixture_manifests(['test_app.pp'])
148
- output,has_errors = subject.check(files)
149
-
150
- expect(has_errors).to eq(true)
151
- expect(output).to include(/error/)
152
- end
153
- end
154
- context 'app_management = true' do
155
- before(:each) {
156
- PuppetSyntax.app_management = true
157
- }
158
- if Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0
159
- it 'should successfully parse an application manifest on Puppet >= 4.3.0' do
160
- expect(PuppetSyntax.app_management).to eq(true)
161
-
162
- files = fixture_manifests(['test_app.pp'])
163
- output,has_errors = subject.check(files)
164
-
165
- expect(output.size).to eq(0)
166
- expect(has_errors).to eq(false)
167
- end
168
- else
169
- it 'should fail to parse an application manifest on Puppet < 4.3.0' do
170
- expect(PuppetSyntax.app_management).to eq(true)
171
-
172
- files = fixture_manifests(['test_app.pp'])
173
- output,has_errors = subject.check(files)
174
-
175
- expect(output).to include(/error/)
176
- expect(has_errors).to eq(true)
177
- end
178
- end
179
- end
180
- end
181
-
182
-
183
- describe 'future_parser' do
184
- context 'future_parser = false (default)' do
185
- if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') < 0
186
- it 'should fail without setting future option to true on future manifest on Puppet < 4.0.0' do
187
- expect(PuppetSyntax.future_parser).to eq(false)
188
-
189
- files = fixture_manifests(['future_syntax.pp'])
190
- output, has_errors = subject.check(files)
191
-
192
- expect(output.size).to eq(1)
193
- expect(output[0]).to match(/Syntax error at '='; expected '\}' .*:2$/)
194
- expect(has_errors).to eq(true)
195
- end
196
- else
197
- it 'should succeed on Puppet >= 4.0.0' do
198
- expect(PuppetSyntax.future_parser).to eq(false)
199
-
200
- files = fixture_manifests(['future_syntax.pp'])
201
- output, has_errors = subject.check(files)
202
-
203
- expect(output.size).to eq(0)
204
- expect(has_errors).to eq(false)
205
- end
206
- end
207
- end
208
-
209
- context 'future_parser = true' do
210
- before(:each) {
211
- PuppetSyntax.future_parser = true
212
- }
213
-
214
- if Puppet::Util::Package.versioncmp(Puppet.version, '3.2') >= 0 and Puppet.version.to_i < 4
215
- context 'Puppet >= 3.2 < 4' do
216
- it 'should pass with future option set to true on future manifest' do
217
- files = fixture_manifests(['future_syntax.pp'])
218
- output, has_errors = subject.check(files)
219
-
220
- expect(output).to eq([])
221
- expect(has_errors).to eq(false)
222
- end
223
- end
224
- context 'Puppet >= 3.7 < 4' do
225
- # Certain elements of the future parser weren't added until 3.7
226
- if Puppet::Util::Package.versioncmp(Puppet.version, '3.7') >= 0
227
- it 'should fail on what were deprecation notices in the non-future parser' do
228
- files = fixture_manifests('deprecation_notice.pp')
229
- output, has_errors = subject.check(files)
230
-
231
- expect(output.size).to eq(1)
232
- expect(output[0]).to match(/Node inheritance is not supported/)
233
- expect(has_errors).to eq(true)
234
- end
235
- end
236
- end
237
- elsif Puppet::Util::Package.versioncmp(Puppet.version, '3.2') < 0
238
- context 'Puppet < 3.2' do
239
- it 'should return an error that the parser option is not supported' do
240
- files = fixture_manifests(['future_syntax.pp'])
241
- output, has_errors = subject.check(files)
242
-
243
- expect(output.size).to eq(1)
244
- expect(output[0]).to match("Attempt to assign a value to unknown configuration parameter :parser")
245
- expect(has_errors).to eq(true)
246
- end
247
- end
248
- end
90
+ expect(has_errors).to eq(true)
91
+ expect(output.size).to eq(1)
92
+ expect(output[0]).to match (/Node inheritance is not supported in Puppet >= 4.0.0/)
249
93
  end
250
94
  end
251
-
252
95
  end
@@ -18,7 +18,7 @@ describe 'PuppetSyntax rake tasks' do
18
18
  it 'should generate FileList of manifests relative to Rakefile' do
19
19
  list = PuppetSyntax::RakeTask.new.filelist_manifests
20
20
  expect(list).to include(known_pp)
21
- expect(list.count).to eq 8
21
+ expect(list.count).to eq 9
22
22
  end
23
23
 
24
24
  it 'should generate FileList of templates relative to Rakefile' do
@@ -2,6 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe PuppetSyntax::Templates do
4
4
  let(:subject) { PuppetSyntax::Templates.new }
5
+ let(:conditional_warning_regex) do
6
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
7
+ %r{2: warning: found `= literal' in conditional}
8
+ else
9
+ %r{2: warning: found = in conditional}
10
+ end
11
+ end
5
12
 
6
13
  it 'should expect an array of files' do
7
14
  expect { subject.check(nil) }.to raise_error(/Expected an array of files/)
@@ -34,7 +41,7 @@ describe PuppetSyntax::Templates do
34
41
  res = subject.check(files)
35
42
 
36
43
  expect(res.size).to eq(1)
37
- expect(res[0]).to match(/2: warning: found = in conditional/)
44
+ expect(res[0]).to match(conditional_warning_regex)
38
45
  end
39
46
 
40
47
  it 'should read more than one valid file' do
@@ -50,7 +57,7 @@ describe PuppetSyntax::Templates do
50
57
 
51
58
  expect(res.size).to eq(2)
52
59
  expect(res[0]).to match(/2: syntax error, unexpected/)
53
- expect(res[1]).to match(/2: warning: found = in conditional/)
60
+ expect(res[1]).to match(conditional_warning_regex)
54
61
  end
55
62
 
56
63
  it 'should ignore a TypeError' do
@@ -67,71 +74,47 @@ describe PuppetSyntax::Templates do
67
74
  expect(res).to match([])
68
75
  end
69
76
 
70
- if Puppet.version.to_f < 3.7
71
- context 'on Puppet < 3.7' do
72
- it 'should throw an exception when parsing EPP files' do
73
- file = fixture_templates('pass.epp')
74
- expect{ subject.check(file) }.to raise_error(/Cannot validate EPP without Puppet 4/)
75
- end
76
-
77
- context "when the 'epp_only' options is set" do
78
- before(:each) {
79
- PuppetSyntax.epp_only = true
80
- }
81
-
82
- it 'should throw an exception for any file' do
83
- file = fixture_templates('pass.erb')
84
- expect{ subject.check(file) }.to raise_error(/Cannot validate EPP without Puppet 4/)
85
- end
86
- end
87
- end
88
- end
89
-
90
- if Puppet.version.to_f >= 3.7
91
- context 'on Puppet >= 3.7' do
92
- it 'should return nothing from a valid file' do
93
- files = fixture_templates('pass.epp')
94
- res = subject.check(files)
77
+ it 'should return nothing from a valid file' do
78
+ files = fixture_templates('pass.epp')
79
+ res = subject.check(files)
95
80
 
96
- expect(res).to match([])
97
- end
81
+ expect(res).to match([])
82
+ end
98
83
 
99
- it 'should catch SyntaxError' do
100
- files = fixture_templates('fail_error.epp')
101
- res = subject.check(files)
84
+ it 'should catch SyntaxError' do
85
+ files = fixture_templates('fail_error.epp')
86
+ res = subject.check(files)
102
87
 
103
- expect(res.size).to eq(1)
104
- expect(res[0]).to match(/This Type-Name has no effect/)
105
- end
88
+ expect(res.size).to eq(1)
89
+ expect(res[0]).to match(/This Type-Name has no effect/)
90
+ end
106
91
 
107
- it 'should read more than one valid file' do
108
- files = fixture_templates(['pass.epp', 'pass_also.epp'])
109
- res = subject.check(files)
92
+ it 'should read more than one valid file' do
93
+ files = fixture_templates(['pass.epp', 'pass_also.epp'])
94
+ res = subject.check(files)
110
95
 
111
- expect(res).to match([])
112
- end
96
+ expect(res).to match([])
97
+ end
113
98
 
114
- it 'should continue after finding an error in the first file' do
115
- files = fixture_templates(['fail_error.epp', 'fail_error_also.epp'])
116
- res = subject.check(files)
99
+ it 'should continue after finding an error in the first file' do
100
+ files = fixture_templates(['fail_error.epp', 'fail_error_also.epp'])
101
+ res = subject.check(files)
117
102
 
118
- expect(res.size).to eq(2)
119
- expect(res[0]).to match(/This Type-Name has no effect/)
120
- expect(res[1]).to match(/Syntax error at '}' \(file: \S*\/fail_error_also.epp, line: 2, column: 4\)/)
121
- end
103
+ expect(res.size).to eq(2)
104
+ expect(res[0]).to match(/This Type-Name has no effect/)
105
+ expect(res[1]).to match(/Syntax error at '}' \(file: \S*\/fail_error_also.epp, line: 2, column: 4\)/)
106
+ end
122
107
 
123
- context "when the 'epp_only' options is set" do
124
- before(:each) {
125
- PuppetSyntax.epp_only = true
126
- }
108
+ context "when the 'epp_only' options is set" do
109
+ before(:each) {
110
+ PuppetSyntax.epp_only = true
111
+ }
127
112
 
128
- it 'should process an ERB as EPP and find an error' do
129
- files = fixture_templates('pass.erb')
130
- res = subject.check(files)
113
+ it 'should process an ERB as EPP and find an error' do
114
+ files = fixture_templates('pass.erb')
115
+ res = subject.check(files)
131
116
 
132
- expect(res.size).to eq(1)
133
- end
134
- end
117
+ expect(res.size).to eq(1)
135
118
  end
136
119
  end
137
120
  end
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
  describe PuppetSyntax do
4
4
  after do
5
5
  PuppetSyntax.exclude_paths = []
6
- PuppetSyntax.app_management = false if Puppet.version.to_i < 5
7
6
  end
8
7
 
9
8
  it 'should default exclude_paths to include the pkg directory' do
@@ -20,20 +19,6 @@ describe PuppetSyntax do
20
19
  expect(PuppetSyntax.exclude_paths).to eq(["foo"])
21
20
  end
22
21
 
23
- it 'should support future parser setting' do
24
- PuppetSyntax.future_parser = true
25
- expect(PuppetSyntax.future_parser).to eq(true)
26
- end
27
-
28
- it 'should support app_management setting setting' do
29
- PuppetSyntax.app_management = true
30
- expect(PuppetSyntax.app_management).to eq(true)
31
- end
32
-
33
- it 'should raise error when app_management is disabled on 5.x', :if => (Puppet.version.to_i >= 5) do
34
- expect { PuppetSyntax.app_management = false }.to raise_error(/app_management cannot be disabled on Puppet 5 or higher/)
35
- end
36
-
37
22
  it 'should support a fail_on_deprecation_notices setting' do
38
23
  PuppetSyntax.fail_on_deprecation_notices = false
39
24
  expect(PuppetSyntax.fail_on_deprecation_notices).to eq(false)
@@ -44,4 +29,12 @@ describe PuppetSyntax do
44
29
  expect(PuppetSyntax.epp_only).to eq(true)
45
30
  end
46
31
 
32
+ it 'should support setting paths for manifests, templates and hiera' do
33
+ PuppetSyntax.hieradata_paths = []
34
+ expect(PuppetSyntax.hieradata_paths).to eq([])
35
+ PuppetSyntax.manifests_paths = ["**/environments/production/**/*.pp"]
36
+ expect(PuppetSyntax.manifests_paths).to eq(["**/environments/production/**/*.pp"])
37
+ PuppetSyntax.templates_paths = []
38
+ expect(PuppetSyntax.templates_paths).to eq([])
39
+ end
47
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-syntax
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-09 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: puppet
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pry
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +95,6 @@ files:
81
95
  - LICENSE.txt
82
96
  - README.md
83
97
  - Rakefile
84
- - jenkins.sh
85
98
  - lib/puppet-syntax.rb
86
99
  - lib/puppet-syntax/hiera.rb
87
100
  - lib/puppet-syntax/manifests.rb
@@ -105,6 +118,7 @@ files:
105
118
  - spec/fixtures/test_module/manifests/future_syntax.pp
106
119
  - spec/fixtures/test_module/manifests/pass.pp
107
120
  - spec/fixtures/test_module/manifests/pass_storeconfigs.pp
121
+ - spec/fixtures/test_module/manifests/schedule_notice.pp
108
122
  - spec/fixtures/test_module/manifests/tag_notice.pp
109
123
  - spec/fixtures/test_module/manifests/test_app.pp
110
124
  - spec/fixtures/test_module/templates/fail_error.epp
@@ -135,14 +149,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
- version: '0'
152
+ version: '2.4'
139
153
  required_rubygems_version: !ruby/object:Gem::Requirement
140
154
  requirements:
141
155
  - - ">="
142
156
  - !ruby/object:Gem::Version
143
157
  version: '0'
144
158
  requirements: []
145
- rubygems_version: 3.0.2
159
+ rubygems_version: 3.0.6
146
160
  signing_key:
147
161
  specification_version: 4
148
162
  summary: Syntax checks for Puppet manifests, templates, and Hiera YAML
@@ -163,6 +177,7 @@ test_files:
163
177
  - spec/fixtures/test_module/manifests/future_syntax.pp
164
178
  - spec/fixtures/test_module/manifests/pass.pp
165
179
  - spec/fixtures/test_module/manifests/pass_storeconfigs.pp
180
+ - spec/fixtures/test_module/manifests/schedule_notice.pp
166
181
  - spec/fixtures/test_module/manifests/tag_notice.pp
167
182
  - spec/fixtures/test_module/manifests/test_app.pp
168
183
  - spec/fixtures/test_module/templates/fail_error.epp
data/jenkins.sh DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -eu
3
-
4
- # Avoid Psych bug in Ruby 1.9.3p0 on Ubuntu 12.04
5
- export RBENV_VERSION="1.9.3"
6
-
7
- rm -f Gemfile.lock
8
- bundle install --path "${HOME}/bundles/${JOB_NAME}" --shebang ruby
9
- bundle exec rake
10
- bundle exec rake publish_gem