puppet-syntax-2.0.0/0000775000175000017500000000000012602303375014231 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/puppet-syntax.gemspec0000644000175000017500000000172112602303375020436 0ustar gaudenzgaudenz# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'puppet-syntax/version' Gem::Specification.new do |spec| spec.name = "puppet-syntax" spec.version = PuppetSyntax::VERSION spec.authors = ["Dan Carley"] spec.email = ["dan.carley@gmail.com"] spec.description = %q{Syntax checks for Puppet manifests and templates} spec.summary = %q{Syntax checks for Puppet manifests, templates, and Hiera YAML} spec.homepage = "https://github.com/gds-operations/puppet-syntax" spec.license = "MIT" spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_dependency "rake" spec.add_development_dependency "rspec" spec.add_development_dependency "gem_publisher", "~> 1.3" end puppet-syntax-2.0.0/Gemfile0000644000175000017500000000033412602303375015522 0ustar gaudenzgaudenzsource 'https://rubygems.org' # Specify your gem's dependencies in puppet-syntax.gemspec gemspec # Override gemspec for CI matrix builds. puppet_version = ENV['PUPPET_VERSION'] || '>2.7.0' gem 'puppet', puppet_version puppet-syntax-2.0.0/.gitignore0000644000175000017500000000024212602303375016215 0ustar gaudenzgaudenz*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp vendor/ puppet-syntax-2.0.0/spec/0000775000175000017500000000000012602303375015163 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/fixtures/0000775000175000017500000000000012602303375017034 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/fixtures/hiera/0000775000175000017500000000000012602303375020124 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/fixtures/hiera/hiera_bad_18.yaml0000644000175000017500000000001712602303375023212 0ustar gaudenzgaudenz--- !!!str foo puppet-syntax-2.0.0/spec/fixtures/hiera/hiera_bad.yaml0000644000175000017500000000001112602303375022674 0ustar gaudenzgaudenz%YAMLBAD puppet-syntax-2.0.0/spec/fixtures/hiera/hiera_good.yaml0000644000175000017500000000012512602303375023104 0ustar gaudenzgaudenz--- :backends: - yaml :yaml: :datadir: './hieradata/good' :hierarchy: - common puppet-syntax-2.0.0/spec/fixtures/test_module/0000775000175000017500000000000012602303375021360 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/fixtures/test_module/manifests/0000775000175000017500000000000012602303375023351 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/fixtures/test_module/manifests/future_syntax.pp0000644000175000017500000000006212602303375026626 0ustar gaudenzgaudenzclass module_with_future_syntax { $a = $b = 10 } puppet-syntax-2.0.0/spec/fixtures/test_module/manifests/pass.pp0000644000175000017500000000015212602303375024654 0ustar gaudenzgaudenzclass normal_puppet_module { notify { 'should should pass': message => 'with flying colours', } } puppet-syntax-2.0.0/spec/fixtures/test_module/manifests/deprecation_notice.pp0000644000175000017500000000024512602303375027547 0ustar gaudenzgaudenznode test inherits default { import 'pass.pp' notify { 'this should give a deprecation notice': message => 'inheritance is gone in the future parser', } } puppet-syntax-2.0.0/spec/fixtures/test_module/manifests/pass_storeconfigs.pp0000644000175000017500000000006712602303375027446 0ustar gaudenzgaudenzclass uses_storeconfigs { @@notify { 'exported': } } puppet-syntax-2.0.0/spec/fixtures/test_module/manifests/fail_warning.pp0000644000175000017500000000020212602303375026342 0ustar gaudenzgaudenzclass warning_puppet_module { notify { 'this should raise a warning': message => "because of \[\] escape characters", } } puppet-syntax-2.0.0/spec/fixtures/test_module/manifests/fail_error.pp0000644000175000017500000000010412602303375026027 0ustar gaudenzgaudenzclass failing_puppet_module { this is not a valid resource name } puppet-syntax-2.0.0/spec/fixtures/test_module/templates/0000775000175000017500000000000012602303375023356 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/fixtures/test_module/templates/typeerror_shouldwin.erb0000644000175000017500000000012612602303375030174 0ustar gaudenzgaudenz#this is valid syntax <%= File.dirname(@the_path_of_the_file_you_first_thought_of) %> puppet-syntax-2.0.0/spec/fixtures/test_module/templates/fail_error.erb0000644000175000017500000000011012602303375026162 0ustar gaudenzgaudenzThis is plain text <% This is not valid Ruby %> This is also plain text puppet-syntax-2.0.0/spec/fixtures/test_module/templates/fail_warning.erb0000644000175000017500000000010312602303375026500 0ustar gaudenzgaudenzAssignment in condition should warn. <%= "oh yes" if foo = true %> puppet-syntax-2.0.0/spec/fixtures/test_module/templates/pass.erb0000644000175000017500000000007112602303375025012 0ustar gaudenzgaudenz<% valid = 'valid' -%> This is a <%= valid -%> template. puppet-syntax-2.0.0/spec/fixtures/test_module/templates/pass_unbound_var.erb0000644000175000017500000000005012602303375027411 0ustar gaudenzgaudenz<%= this_variable_has_not_been_bound %> puppet-syntax-2.0.0/spec/puppet-syntax/0000775000175000017500000000000012602303375020024 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/puppet-syntax/hiera_spec.rb0000644000175000017500000000145612602303375022457 0ustar gaudenzgaudenzrequire 'spec_helper' describe PuppetSyntax::Hiera do let(:subject) { PuppetSyntax::Hiera.new } it 'should expect an array of files' do expect { subject.check(nil) }.to raise_error(/Expected an array of files/) end it "should return nothing from valid YAML" do files = fixture_hiera('hiera_good.yaml') res = subject.check(files) expect(res).to be == [] end it "should return an error from invalid YAML" do case RUBY_VERSION when /1.8/ files = fixture_hiera('hiera_bad_18.yaml') expected = /syntax error on line 3, col -1: `'/ else files = fixture_hiera('hiera_bad.yaml') expected = /scanning a directive at line 1 column 1/ end res = subject.check(files) expect(res.size).to be == 1 expect(res.first).to match(expected) end end puppet-syntax-2.0.0/spec/puppet-syntax/manifests_spec.rb0000644000175000017500000001313412602303375023354 0ustar gaudenzgaudenzrequire 'spec_helper' require 'puppet' describe PuppetSyntax::Manifests do let(:subject) { PuppetSyntax::Manifests.new } it 'should expect an array of files' do expect { subject.check(nil) }.to raise_error(/Expected an array of files/) end it 'should return nothing from a valid file' do files = fixture_manifests('pass.pp') output, has_errors = subject.check(files) expect(output).to eq([]) expect(has_errors).to eq(false) end it 'should return an error from an invalid file' do files = fixture_manifests('fail_error.pp') output, has_errors = subject.check(files) expect(output.size).to eq(1) expect(output[0]).to match(/Syntax error at .*:3$/) expect(has_errors).to eq(true) end it 'should return a warning from an invalid file' do files = fixture_manifests('fail_warning.pp') output, has_errors = subject.check(files) expect(output.size).to eq(2) expect(output[0]).to match(/Unrecognised escape sequence '\\\[' .* at line 3$/) expect(output[1]).to match(/Unrecognised escape sequence '\\\]' .* at line 3$/) expect(has_errors).to eq(true) end it 'should ignore warnings about storeconfigs' do files = fixture_manifests('pass_storeconfigs.pp') output, has_errors = subject.check(files) expect(output).to eq([]) expect(has_errors).to eq(false) end it 'should read more than one valid file' do files = fixture_manifests(['pass.pp', 'pass_storeconfigs.pp']) output, has_errors = subject.check(files) expect(output).to eq([]) expect(has_errors).to eq(false) end it 'should continue after finding an error in the first file' do files = fixture_manifests(['fail_error.pp', 'fail_warning.pp']) output, has_errors = subject.check(files) expect(output.size).to eq(3) expect(output[0]).to match(/Syntax error at '\}' .*:3$/) expect(output[1]).to match(/Unrecognised escape sequence '\\\[' .* at line 3$/) expect(output[2]).to match(/Unrecognised escape sequence '\\\]' .* at line 3$/) expect(has_errors).to eq(true) end describe 'deprecation notices' do # These tests should fail in Puppet 4, but we need to wait for the release # before we'll know exactly how to test it. if Puppet::Util::Package.versioncmp(Puppet.version, '3.7') >= 0 context 'on puppet >= 3.7' do it 'should return deprecation notices as warnings' do files = fixture_manifests('deprecation_notice.pp') output, has_errors = subject.check(files) expect(has_errors).to eq(false) expect(output.size).to eq(2) expect(output[0]).to match(/The use of 'import' is deprecated/) expect(output[1]).to match(/Deprecation notice:/) end end elsif Puppet::Util::Package.versioncmp(Puppet.version, '3.5') >= 0 context 'on puppet 3.5 and 3.6' do it 'should return deprecation notices as warnings' do files = fixture_manifests('deprecation_notice.pp') output, has_errors = subject.check(files) expect(has_errors).to eq(false) expect(output.size).to eq(1) expect(output[0]).to match(/The use of 'import' is deprecated/) end end elsif Puppet::Util::Package.versioncmp(Puppet.version, '3.5') < 0 context 'on puppet < 3.5' do it 'should not print deprecation notices' do files = fixture_manifests('deprecation_notice.pp') output, has_errors = subject.check(files) expect(output).to eq([]) expect(has_errors).to eq(false) end end end end describe 'future_parser' do context 'future_parser = false (default)' do it 'should fail without setting future option to true on future manifest' do expect(PuppetSyntax.future_parser).to eq(false) files = fixture_manifests(['future_syntax.pp']) output, has_errors = subject.check(files) expect(output.size).to eq(1) expect(output[0]).to match(/Syntax error at '='; expected '\}' .*:2$/) expect(has_errors).to eq(true) end end context 'future_parser = true' do before(:each) { PuppetSyntax.future_parser = true } if Puppet::Util::Package.versioncmp(Puppet.version, '3.2') >= 0 context 'Puppet >= 3.2' do it 'should pass with future option set to true on future manifest' do files = fixture_manifests(['future_syntax.pp']) output, has_errors = subject.check(files) expect(output).to eq([]) expect(has_errors).to eq(false) end end context 'Puppet >= 3.7' do # Certain elements of the future parser weren't added until 3.7 if Puppet::Util::Package.versioncmp(Puppet.version, '3.7') >= 0 it 'should fail on what were deprecation notices in the non-future parser' do files = fixture_manifests('deprecation_notice.pp') output, has_errors = subject.check(files) expect(output.size).to eq(1) expect(output[0]).to match(/Node inheritance is not supported/) expect(has_errors).to eq(true) end end end else context 'Puppet < 3.2' do it 'should return an error that the parser option is not supported' do files = fixture_manifests(['future_syntax.pp']) output, has_errors = subject.check(files) expect(output.size).to eq(1) expect(output[0]).to match("Attempt to assign a value to unknown configuration parameter :parser") expect(has_errors).to eq(true) end end end end end end puppet-syntax-2.0.0/spec/puppet-syntax/tasks/0000775000175000017500000000000012602303375021151 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/spec/puppet-syntax/tasks/puppet-syntax_spec.rb0000644000175000017500000000063412602303375025352 0ustar gaudenzgaudenzrequire 'spec_helper' describe 'PuppetSyntax rake tasks' do it 'should generate FileList of manifests relative to Rakefile' do if RSpec::Version::STRING < '3' pending else skip('needs to be done') end end it 'should generate FileList of templates relative to Rakefile' do if RSpec::Version::STRING < '3' pending else skip('needs to be done') end end end puppet-syntax-2.0.0/spec/puppet-syntax/templates_spec.rb0000644000175000017500000000322712602303375023363 0ustar gaudenzgaudenzrequire 'spec_helper' describe PuppetSyntax::Templates do let(:subject) { PuppetSyntax::Templates.new } it 'should expect an array of files' do expect { subject.check(nil) }.to raise_error(/Expected an array of files/) end it 'should return nothing from a valid file' do files = fixture_templates('pass.erb') res = subject.check(files) expect(res).to match([]) end it 'should ignore NameErrors from unbound variables' do files = fixture_templates('pass_unbound_var.erb') res = subject.check(files) expect(res).to match([]) end it 'should catch SyntaxError' do files = fixture_templates('fail_error.erb') res = subject.check(files) expect(res.size).to eq(1) expect(res[0]).to match(/2: syntax error, unexpected/) end it 'should catch Ruby warnings' do files = fixture_templates('fail_warning.erb') res = subject.check(files) expect(res.size).to eq(1) expect(res[0]).to match(/2: warning: found = in conditional/) end it 'should read more than one valid file' do files = fixture_templates(['pass.erb', 'pass_unbound_var.erb']) res = subject.check(files) expect(res).to match([]) end it 'should continue after finding an error in the first file' do files = fixture_templates(['fail_error.erb', 'fail_warning.erb']) res = subject.check(files) 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/) end it 'should ignore a TypeError' do files = fixture_templates('typeerror_shouldwin.erb') res = subject.check(files) expect(res).to match([]) end end puppet-syntax-2.0.0/spec/puppet-syntax_spec.rb0000644000175000017500000000154712602303375021370 0ustar gaudenzgaudenzrequire 'spec_helper' describe PuppetSyntax do after do PuppetSyntax.exclude_paths = [] end it 'should default exclude_paths to empty array' do expect(PuppetSyntax.exclude_paths).to be_empty end it 'should support setting exclude_paths' do PuppetSyntax.exclude_paths = ["foo", "bar/baz"] expect(PuppetSyntax.exclude_paths).to eq(["foo", "bar/baz"]) end it 'should support appending exclude_paths' do PuppetSyntax.exclude_paths << "foo" expect(PuppetSyntax.exclude_paths).to eq(["foo"]) end it 'should support future parser setting' do PuppetSyntax.future_parser = true expect(PuppetSyntax.future_parser).to eq(true) end it 'should support a fail_on_deprecation_notices setting' do PuppetSyntax.fail_on_deprecation_notices = false expect(PuppetSyntax.fail_on_deprecation_notices).to eq(false) end end puppet-syntax-2.0.0/spec/spec_helper.rb0000644000175000017500000000075112602303375020002 0ustar gaudenzgaudenzrequire 'rspec' require 'puppet-syntax' def fixture_hiera(list) fixture_files(list, 'hiera') end def fixture_templates(list) fixture_files(list, 'test_module/templates') end def fixture_manifests(list) fixture_files(list, 'test_module/manifests') end def fixture_files(list, path) list = [list].flatten list.map { |f| File.expand_path("../fixtures/#{path}/#{f}", __FILE__) } end RSpec.configure do |config| config.color = true config.formatter = 'documentation' end puppet-syntax-2.0.0/jenkins.sh0000755000175000017500000000036112602303375016227 0ustar gaudenzgaudenz#!/usr/bin/env bash set -eu # Avoid Psych bug in Ruby 1.9.3p0 on Ubuntu 12.04 export RBENV_VERSION="1.9.3" rm -f Gemfile.lock bundle install --path "${HOME}/bundles/${JOB_NAME}" --shebang ruby bundle exec rake bundle exec rake publish_gem puppet-syntax-2.0.0/CHANGELOG0000644000175000017500000000337012602303375015444 0ustar gaudenzgaudenz2015-02-25 Release 2.0.0 - Removed support for Puppet version 2.7.x - New option, fail_on_deprecation_notices, which defaults to true (compatible with previous behaviour); thanks @pcfens - PuppetSyntax::Manifests#check now has two return arguments 2015-01-08 Release 1.4.1 - Support appending to config arrays, thanks @domcleal 2014-12-04 Release 1.4.0 - Rspec 3 is now supported, thanks @tuxmea - Build error fixed where gem_publisher was used prematurely - Lazy load Puppet only when it's required, thanks @logicminds 2014-08-07 Release 1.3.0 - Add the ability to pass hieradata_paths array of globs to check - Check hieradata in modules ('**/data/**/*.yaml') by default 2014-08-05 Release 1.2.3 - Fix puppetlabs_spec_helper warning on Ruby 1.8 2014-07-31 Release 1.2.2 - Check and document conflicts with puppetlabs_spec_helper <= 0.7.0 2014-07-23 Release 1.2.1 - Remove dependency on Puppet from Gemspec (for Puppet Entreprise users). 2014-03-28 Release 1.2.0 - Optional support for Puppet's future parser. 2014-03-17 Release 1.1.1 - Ignore exit(1) from Puppet 3.4 - Don't use hardcoded version of parser face. 2013-09-06 Release 1.1.0 - Syntax checks for Hiera YAML files. - Improved documentation. 2013-07-04 Release 1.0.0 - Refactor code to make it easier to test. - Implement spec tests for syntax checks. - Pending spec tests for FileList matching. - Matrix tests for other Ruby/Puppet versions. - Improve usage example in README. 2013-06-14 Release 0.0.4 - Fix `$confdir` error for Puppet 3.x 2013-06-11 Release 0.0.3 - List rake as a dependency. - Output names of tasks to STDERR. - Match template paths correctly. - Add pending spec tests, not yet working. 2013-06-10 Release 0.0.2 - Fix namespacing of rake tasks. 2013-06-10 Release 0.0.1 - Initial release puppet-syntax-2.0.0/lib/0000775000175000017500000000000012602303375014777 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/lib/puppet-syntax.rb0000644000175000017500000000067112602303375020167 0ustar gaudenzgaudenzrequire "puppet-syntax/version" require "puppet-syntax/manifests" require "puppet-syntax/templates" require "puppet-syntax/hiera" module PuppetSyntax @exclude_paths = [] @future_parser = false @hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"] @fail_on_deprecation_notices = true class << self attr_accessor :exclude_paths, :future_parser, :hieradata_paths, :fail_on_deprecation_notices end end puppet-syntax-2.0.0/lib/puppet-syntax/0000775000175000017500000000000012602303375017640 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/lib/puppet-syntax/templates.rb0000644000175000017500000000176612602303375022173 0ustar gaudenzgaudenzrequire 'erb' require 'stringio' module PuppetSyntax class Templates def check(filelist) raise "Expected an array of files" unless filelist.is_a?(Array) # We now have to redirect STDERR in order to capture warnings. $stderr = warnings = StringIO.new() errors = [] filelist.each do |erb_file| begin erb = ERB.new(File.read(erb_file), nil, '-') erb.filename = erb_file erb.result rescue NameError # This is normal because we don't have the variables that would # ordinarily be bound by the parent Puppet manifest. rescue TypeError # This is normal because we don't have the variables that would # ordinarily be bound by the parent Puppet manifest. rescue SyntaxError => error errors << error end end $stderr = STDERR errors << warnings.string unless warnings.string.empty? errors.map! { |e| e.to_s } errors end end end puppet-syntax-2.0.0/lib/puppet-syntax/manifests.rb0000644000175000017500000000314712602303375022161 0ustar gaudenzgaudenzmodule PuppetSyntax class Manifests def check(filelist) raise "Expected an array of files" unless filelist.is_a?(Array) require 'puppet' require 'puppet/face' output = [] # FIXME: We shouldn't need to do this. puppet/face should. See: # - http://projects.puppetlabs.com/issues/15529 # - https://groups.google.com/forum/#!topic/puppet-dev/Yk0WC1JZCg8/discussion if (Puppet::PUPPETVERSION.to_i >= 3 && !Puppet.settings.app_defaults_initialized?) Puppet.initialize_settings end # Catch syntax warnings. Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(output)) Puppet::Util::Log.level = :warning filelist.each do |puppet_file| begin validate_manifest(puppet_file) rescue SystemExit # Disregard exit(1) from face. rescue => error output << error end end Puppet::Util::Log.close_all output.map! { |e| e.to_s } # Exported resources will raise warnings when outside a puppetmaster. output.reject! { |e| e =~ /^You cannot collect( exported resources)? without storeconfigs being set/ } deprecations = output.select { |e| e =~ /^Deprecation notice:|is deprecated/ } # Errors exist if there is any output that isn't a deprecation notice. has_errors = (output != deprecations) return output, has_errors end private def validate_manifest(file) Puppet[:parser] = 'future' if PuppetSyntax.future_parser Puppet::Face[:parser, :current].validate(file) end end end puppet-syntax-2.0.0/lib/puppet-syntax/hiera.rb0000644000175000017500000000062012602303375021251 0ustar gaudenzgaudenzrequire 'yaml' module PuppetSyntax class Hiera def check(filelist) raise "Expected an array of files" unless filelist.is_a?(Array) errors = [] filelist.each do |hiera_file| begin YAML.load_file(hiera_file) rescue Exception => error errors << error end end errors.map! { |e| e.to_s } errors end end end puppet-syntax-2.0.0/lib/puppet-syntax/tasks/0000775000175000017500000000000012602303375020765 5ustar gaudenzgaudenzpuppet-syntax-2.0.0/lib/puppet-syntax/tasks/puppet-syntax.rb0000644000175000017500000000457412602303375024163 0ustar gaudenzgaudenzrequire 'puppet-syntax' require 'rake' require 'rake/tasklib' module PuppetSyntax class RakeTask < ::Rake::TaskLib def initialize(*args) desc 'Syntax check Puppet manifests and templates' task :syntax => [ 'syntax:check_puppetlabs_spec_helper', 'syntax:manifests', 'syntax:templates', 'syntax:hiera', ] namespace :syntax do task :check_puppetlabs_spec_helper do psh_present = Rake::Task[:syntax].actions.any? { |a| a.inspect.match(/puppetlabs_spec_helper\/rake_tasks\.rb:\d+/) } if psh_present warn <<-EOS [WARNING] A conflicting :syntax rake task has been defined by puppetlabs_spec_helper/rake_tasks. You should either disable this or upgrade to puppetlabs_spec_helper >= 0.8.0 which now uses puppet-syntax. EOS end end desc 'Syntax check Puppet manifests' task :manifests do |t| $stderr.puts "---> #{t.name}" files = FileList["**/*.pp"] files.reject! { |f| File.directory?(f) } files = files.exclude(*PuppetSyntax.exclude_paths) c = PuppetSyntax::Manifests.new output, has_errors = c.check(files) print "#{output.join("\n")}\n" unless output.empty? fail if has_errors || ( output.any? && PuppetSyntax.fail_on_deprecation_notices ) end desc 'Syntax check Puppet templates' task :templates do |t| $stderr.puts "---> #{t.name}" files = FileList["**/templates/**/*"] files.reject! { |f| File.directory?(f) } files = files.exclude(*PuppetSyntax.exclude_paths) c = PuppetSyntax::Templates.new errors = c.check(files) fail errors.join("\n") unless errors.empty? end desc 'Syntax check Hiera config files' task :hiera => [ 'syntax:hiera:yaml', ] namespace :hiera do task :yaml do |t| $stderr.puts "---> #{t.name}" files = FileList.new(PuppetSyntax.hieradata_paths) files.reject! { |f| File.directory?(f) } files = files.exclude(*PuppetSyntax.exclude_paths) c = PuppetSyntax::Hiera.new errors = c.check(files) fail errors.join("\n") unless errors.empty? end end end end end end PuppetSyntax::RakeTask.new puppet-syntax-2.0.0/lib/puppet-syntax/version.rb0000644000175000017500000000005412602303375021647 0ustar gaudenzgaudenzmodule PuppetSyntax VERSION = "2.0.0" end puppet-syntax-2.0.0/LICENSE.txt0000644000175000017500000000205312602303375016052 0ustar gaudenzgaudenzCopyright (c) 2013 Dan Carley MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. puppet-syntax-2.0.0/metadata.yml0000664000175000017500000001061412602303375016536 0ustar gaudenzgaudenz--- !ruby/object:Gem::Specification name: puppet-syntax version: !ruby/object:Gem::Version version: 2.0.0 prerelease: platform: ruby authors: - Dan Carley autorequire: bindir: bin cert_chain: [] date: 2015-02-26 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: gem_publisher requirement: !ruby/object:Gem::Requirement none: false requirements: - - ~> - !ruby/object:Gem::Version version: '1.3' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ~> - !ruby/object:Gem::Version version: '1.3' description: Syntax checks for Puppet manifests and templates email: - dan.carley@gmail.com executables: [] extensions: [] extra_rdoc_files: [] files: - .gitignore - .travis.yml - CHANGELOG - Gemfile - LICENSE.txt - README.md - Rakefile - jenkins.sh - lib/puppet-syntax.rb - lib/puppet-syntax/hiera.rb - lib/puppet-syntax/manifests.rb - lib/puppet-syntax/tasks/puppet-syntax.rb - lib/puppet-syntax/templates.rb - lib/puppet-syntax/version.rb - puppet-syntax.gemspec - spec/fixtures/hiera/hiera_bad.yaml - spec/fixtures/hiera/hiera_bad_18.yaml - spec/fixtures/hiera/hiera_good.yaml - spec/fixtures/test_module/manifests/deprecation_notice.pp - spec/fixtures/test_module/manifests/fail_error.pp - spec/fixtures/test_module/manifests/fail_warning.pp - spec/fixtures/test_module/manifests/future_syntax.pp - spec/fixtures/test_module/manifests/pass.pp - spec/fixtures/test_module/manifests/pass_storeconfigs.pp - spec/fixtures/test_module/templates/fail_error.erb - spec/fixtures/test_module/templates/fail_warning.erb - spec/fixtures/test_module/templates/pass.erb - spec/fixtures/test_module/templates/pass_unbound_var.erb - spec/fixtures/test_module/templates/typeerror_shouldwin.erb - spec/puppet-syntax/hiera_spec.rb - spec/puppet-syntax/manifests_spec.rb - spec/puppet-syntax/tasks/puppet-syntax_spec.rb - spec/puppet-syntax/templates_spec.rb - spec/puppet-syntax_spec.rb - spec/spec_helper.rb homepage: https://github.com/gds-operations/puppet-syntax licenses: - MIT post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' segments: - 0 hash: 2080509366784508245 required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' segments: - 0 hash: 2080509366784508245 requirements: [] rubyforge_project: rubygems_version: 1.8.23.2 signing_key: specification_version: 3 summary: Syntax checks for Puppet manifests, templates, and Hiera YAML test_files: - spec/fixtures/hiera/hiera_bad.yaml - spec/fixtures/hiera/hiera_bad_18.yaml - spec/fixtures/hiera/hiera_good.yaml - spec/fixtures/test_module/manifests/deprecation_notice.pp - spec/fixtures/test_module/manifests/fail_error.pp - spec/fixtures/test_module/manifests/fail_warning.pp - spec/fixtures/test_module/manifests/future_syntax.pp - spec/fixtures/test_module/manifests/pass.pp - spec/fixtures/test_module/manifests/pass_storeconfigs.pp - spec/fixtures/test_module/templates/fail_error.erb - spec/fixtures/test_module/templates/fail_warning.erb - spec/fixtures/test_module/templates/pass.erb - spec/fixtures/test_module/templates/pass_unbound_var.erb - spec/fixtures/test_module/templates/typeerror_shouldwin.erb - spec/puppet-syntax/hiera_spec.rb - spec/puppet-syntax/manifests_spec.rb - spec/puppet-syntax/tasks/puppet-syntax_spec.rb - spec/puppet-syntax/templates_spec.rb - spec/puppet-syntax_spec.rb - spec/spec_helper.rb puppet-syntax-2.0.0/Rakefile0000644000175000017500000000037412602303375015700 0ustar gaudenzgaudenzrequire 'rspec/core/rake_task' RSpec::Core::RakeTask.new('spec') task :publish_gem do require 'gem_publisher' gem = GemPublisher.publish_if_updated('puppet-syntax.gemspec', :rubygems) puts "Published #{gem}" if gem end task :default => [:spec] puppet-syntax-2.0.0/README.md0000644000175000017500000000464712602303375015521 0ustar gaudenzgaudenz[![Build Status](https://travis-ci.org/gds-operations/puppet-syntax.svg?branch=master)](https://travis-ci.org/gds-operations/puppet-syntax) # Puppet::Syntax Syntax checks for Puppet manifests, templates, and Hiera YAML. ## Version support This should work on any version of: - Puppet >= 2.7 that provides the `validate` face. - Ruby >= 1.8 with `erb` from stdlib. You can see the matrix of specific versions that we currently test against in the [TravisCI config](.travis.yml). If you're using `puppetlabs_spec_helper/rake_tasks` and getting unexpected non-zero exit codes then you should upgrade to [puppetlabs_spec_helper][psh] \>= 0.8.0 which no longer has a conflicting rake task and now depends on this project. [psh]: https://github.com/puppetlabs/puppetlabs_spec_helper ## Usage Include the following in your `Rakefile`: require 'puppet-syntax/tasks/puppet-syntax' Test all manifests and templates relative to your `Rakefile`: ➜ puppet git:(master) bundle exec rake syntax ---> syntax:manifests ---> syntax:templates ---> syntax:hiera:yaml A non-zero exit code and error message will be returned for any failures: ➜ puppet git:(master) bundle exec rake syntax ---> syntax:manifests rake aborted! Could not parse for environment production: Syntax error at end of file at demo.pp:2 Tasks: TOP => syntax => syntax:manifests (See full trace by running task with --trace) Use in conjunction with lint and spec tests for Continuous Integration: task :test => [ :syntax, :lint, :spec, ] ## Configuration Paths can be excluded with: PuppetSyntax.exclude_paths = ["vendor/**/*"] When you are using a Puppet version greater then 3.2, you can select the future parse by specifying PuppetSyntax.future_parser = true If you are using some form of hiera data inside your module, you can configure where the `syntax:hiera:yaml` task looks for data with: PuppetSyntax.hieradata_paths = ["**/data/**/*.yaml", "hieradata/**/*.yaml", "hiera*.yaml"] ## Installation Add this line to your application's Gemfile: gem 'puppet-syntax' And then execute: $ bundle Or install it yourself as: $ gem install puppet-syntax ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request puppet-syntax-2.0.0/.travis.yml0000644000175000017500000000045312602303375016342 0ustar gaudenzgaudenz--- language: ruby script: bundle exec rake rvm: - 1.9.3 env: - PUPPET_VERSION="~> 3.0.0" - PUPPET_VERSION="~> 3.1.0" - PUPPET_VERSION="~> 3.2.0" - PUPPET_VERSION="~> 3.4.0" - PUPPET_VERSION="~> 3.7.3" - PUPPET_VERSION=">= 0" matrix: allow_failures: - env: PUPPET_VERSION=">= 0"