From cf809b63a4173fc5971d89fc7b844481a23e47b2 Mon Sep 17 00:00:00 2001 From: Georg Faerber <georg@riseup.net> Date: Tue, 4 Feb 2020 11:09:42 +0000 Subject: [PATCH] New upstream version 2.6.1 --- .travis.yml | 9 ++++++++ CHANGELOG.md | 27 ++++++++++++++++++++++++ Gemfile | 3 ++- README.md | 5 +++++ lib/puppet-syntax.rb | 9 ++++++++ lib/puppet-syntax/hiera.rb | 2 +- lib/puppet-syntax/manifests.rb | 1 + lib/puppet-syntax/tasks/puppet-syntax.rb | 4 ++-- lib/puppet-syntax/version.rb | 2 +- puppet-syntax.gemspec | 1 + spec/puppet-syntax/templates_spec.rb | 11 ++++++++-- spec/puppet-syntax_spec.rb | 8 +++++++ 12 files changed, 75 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91d37ec..f4376ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ --- +dist: bionic language: ruby # Workaround https://github.com/bundler/bundler/issues/3558 before_install: gem install bundler @@ -7,6 +8,7 @@ script: bundle exec rake rvm: - 2.4.4 - 2.5.1 + - 2.6.5 env: - PUPPET_VERSION="~> 5.5.10" - PUPPET_VERSION="~> 6.1.0" @@ -29,3 +31,10 @@ deploy: tags: true all_branches: true repo: voxpupuli/puppet-syntax +notifications: + email: false + irc: + on_success: always + on_failure: always + channels: + - "chat.freenode.org#voxpupuli-notifications" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e8e369..7de0f0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,33 @@ All notable changes to this project will be documented in this file. +## [v2.6.1](https://github.com/voxpupuli/puppet-syntax/tree/v2.6.1) (2020-01-11) + +[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.6.0...v2.6.1) + +**Fixed bugs:** + +- Add `puppet` gem as runtime dependency [\#116](https://github.com/voxpupuli/puppet-syntax/pull/116) ([bastelfreak](https://github.com/bastelfreak)) + +**Merged pull requests:** + +- traivs: run tests on Ubuntu 18.04 [\#117](https://github.com/voxpupuli/puppet-syntax/pull/117) ([bastelfreak](https://github.com/bastelfreak)) +- travis: enable irc / disable email notifications [\#114](https://github.com/voxpupuli/puppet-syntax/pull/114) ([bastelfreak](https://github.com/bastelfreak)) + +## [v2.6.0](https://github.com/voxpupuli/puppet-syntax/tree/v2.6.0) (2019-10-05) + +[Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.5.0...v2.6.0) + +**Implemented enhancements:** + +- add support for validating puppet plans \(fixes \#95, fixes \#96\) [\#97](https://github.com/voxpupuli/puppet-syntax/pull/97) ([slauger](https://github.com/slauger)) +- Allow specifying file paths for manifests and templates too [\#87](https://github.com/voxpupuli/puppet-syntax/pull/87) ([lavagetto](https://github.com/lavagetto)) + +**Merged pull requests:** + +- Test on ruby 2.6 [\#111](https://github.com/voxpupuli/puppet-syntax/pull/111) ([alexjfisher](https://github.com/alexjfisher)) +- Adding KMS tags to allowed EYAML methods [\#105](https://github.com/voxpupuli/puppet-syntax/pull/105) ([craigwatson](https://github.com/craigwatson)) + ## [v2.5.0](https://github.com/voxpupuli/puppet-syntax/tree/v2.5.0) (2019-07-07) [Full Changelog](https://github.com/voxpupuli/puppet-syntax/compare/v2.4.3...v2.5.0) diff --git a/Gemfile b/Gemfile index 19a87e8..0a0c20c 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,8 @@ end gemspec # Override gemspec for CI matrix builds. -gem 'puppet', *location_for(ENV['PUPPET_VERSION'] || '>2.7.0') +# But only if the environment variable is set +gem 'puppet', *location_for(ENV['PUPPET_VERSION'] || '>= 5') if ENV['PUPPET_VERSION'] # 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 gem 'json_pure', '<= 2.0.1' diff --git a/README.md b/README.md index 55e5774..f30584a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ To configure Puppet::Syntax, add any of the following settings to your `Rakefile PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"] +* 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. + + PuppetSyntax.manifests_paths = ["**/environments/future/*.pp"] + PuppetSyntax.templates_paths = ["**/modules/**/templates/*.erb"] + * To validate the syntax of code written for application orchestration, enable `app_management`: PuppetSyntax.app_management = true diff --git a/lib/puppet-syntax.rb b/lib/puppet-syntax.rb index 7e5c089..d012911 100644 --- a/lib/puppet-syntax.rb +++ b/lib/puppet-syntax.rb @@ -12,6 +12,13 @@ module PuppetSyntax "hieradata/**/*.*{yaml,yml}", "hiera*.*{yaml,yml}" ] + @manifests_paths = [ + '**/*.pp' + ] + @templates_paths = [ + '**/templates/**/*.erb', + '**/templates/**/*.epp' + ] @fail_on_deprecation_notices = true @app_management = Puppet.version.to_i >= 5 ? true : false @check_hiera_keys = false @@ -20,6 +27,8 @@ module PuppetSyntax attr_accessor :exclude_paths, :future_parser, :hieradata_paths, + :manifests_paths, + :templates_paths, :fail_on_deprecation_notices, :epp_only, :check_hiera_keys diff --git a/lib/puppet-syntax/hiera.rb b/lib/puppet-syntax/hiera.rb index e283c6a..6c9fb8b 100644 --- a/lib/puppet-syntax/hiera.rb +++ b/lib/puppet-syntax/hiera.rb @@ -56,7 +56,7 @@ module PuppetSyntax method = 'PKCS7' end - return "has unknown eyaml method #{method}" unless ['PKCS7','GPG'].include? method + return "has unknown eyaml method #{method}" unless ['PKCS7','GPG','GKMS','KMS'].include? method return "has unpadded or truncated base64 data" unless base64.length % 4 == 0 # Base64#decode64 will silently ignore characters outside the alphabet, diff --git a/lib/puppet-syntax/manifests.rb b/lib/puppet-syntax/manifests.rb index b11b878..a92aa51 100644 --- a/lib/puppet-syntax/manifests.rb +++ b/lib/puppet-syntax/manifests.rb @@ -64,6 +64,7 @@ module PuppetSyntax def validate_manifest(file) Puppet[:parser] = 'future' if PuppetSyntax.future_parser and Puppet.version.to_i < 4 Puppet[:app_management] = true if PuppetSyntax.app_management && (Puppet::Util::Package.versioncmp(Puppet.version, '4.3.0') >= 0 && Puppet.version.to_i < 5) + Puppet[:tasks] = true if Puppet::Util::Package.versioncmp(Puppet.version, '5.4.0') >= 0 and file.match(/.*plans\/.*\.pp$/) Puppet::Face[:parser, :current].validate(file) end end diff --git a/lib/puppet-syntax/tasks/puppet-syntax.rb b/lib/puppet-syntax/tasks/puppet-syntax.rb index 7013dc1..b995600 100644 --- a/lib/puppet-syntax/tasks/puppet-syntax.rb +++ b/lib/puppet-syntax/tasks/puppet-syntax.rb @@ -13,11 +13,11 @@ module PuppetSyntax end def filelist_manifests - filelist("**/*.pp") + filelist(PuppetSyntax.manifests_paths) end def filelist_templates - filelist(["**/templates/**/*.erb", "**/templates/**/*.epp"]) + filelist(PuppetSyntax.templates_paths) end def filelist_hiera_yaml diff --git a/lib/puppet-syntax/version.rb b/lib/puppet-syntax/version.rb index 5eb4f76..1d9a782 100644 --- a/lib/puppet-syntax/version.rb +++ b/lib/puppet-syntax/version.rb @@ -1,3 +1,3 @@ module PuppetSyntax - VERSION = '2.5.0' + VERSION = '2.6.1' end diff --git a/puppet-syntax.gemspec b/puppet-syntax.gemspec index 7731acf..93791c3 100644 --- a/puppet-syntax.gemspec +++ b/puppet-syntax.gemspec @@ -19,6 +19,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "rake" + spec.add_dependency "puppet", ">= 5" spec.add_development_dependency "pry" spec.add_development_dependency "rb-readline" diff --git a/spec/puppet-syntax/templates_spec.rb b/spec/puppet-syntax/templates_spec.rb index bcd10ca..e349c2c 100644 --- a/spec/puppet-syntax/templates_spec.rb +++ b/spec/puppet-syntax/templates_spec.rb @@ -2,6 +2,13 @@ require 'spec_helper' describe PuppetSyntax::Templates do let(:subject) { PuppetSyntax::Templates.new } + let(:conditional_warning_regex) do + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0') + %r{2: warning: found `= literal' in conditional} + else + %r{2: warning: found = in conditional} + end + end it 'should expect an array of files' do expect { subject.check(nil) }.to raise_error(/Expected an array of files/) @@ -34,7 +41,7 @@ describe PuppetSyntax::Templates do res = subject.check(files) expect(res.size).to eq(1) - expect(res[0]).to match(/2: warning: found = in conditional/) + expect(res[0]).to match(conditional_warning_regex) end it 'should read more than one valid file' do @@ -50,7 +57,7 @@ describe PuppetSyntax::Templates do expect(res.size).to eq(2) expect(res[0]).to match(/2: syntax error, unexpected/) - expect(res[1]).to match(/2: warning: found = in conditional/) + expect(res[1]).to match(conditional_warning_regex) end it 'should ignore a TypeError' do diff --git a/spec/puppet-syntax_spec.rb b/spec/puppet-syntax_spec.rb index 7570790..a056bfc 100644 --- a/spec/puppet-syntax_spec.rb +++ b/spec/puppet-syntax_spec.rb @@ -44,4 +44,12 @@ describe PuppetSyntax do expect(PuppetSyntax.epp_only).to eq(true) end + it 'should support setting paths for manifests, templates and hiera' do + PuppetSyntax.hieradata_paths = [] + expect(PuppetSyntax.hieradata_paths).to eq([]) + PuppetSyntax.manifests_paths = ["**/environments/production/**/*.pp"] + expect(PuppetSyntax.manifests_paths).to eq(["**/environments/production/**/*.pp"]) + PuppetSyntax.templates_paths = [] + expect(PuppetSyntax.templates_paths).to eq([]) + end end -- GitLab