Class: PuppetSyntax::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- PuppetSyntax::RakeTask
- Defined in:
- lib/puppet-syntax/tasks/puppet-syntax.rb
Instance Method Summary collapse
- #filelist(paths) ⇒ Object
- #filelist_hiera_yaml ⇒ Object
- #filelist_manifests ⇒ Object
- #filelist_templates ⇒ Object
-
#initialize(*_args) ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize(*_args) ⇒ RakeTask
Returns a new instance of RakeTask.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/puppet-syntax/tasks/puppet-syntax.rb', line 30 def initialize(*_args) desc 'Syntax check for Puppet manifests, templates and Hiera' task syntax: [ 'syntax:manifests', 'syntax:templates', 'syntax:hiera', ] namespace :syntax do desc 'Syntax check Puppet manifests' task :manifests do |t| warn "---> #{t.name}" c = PuppetSyntax::Manifests.new output, has_errors = c.check(filelist_manifests) $stdout.puts "#{output.join("\n")}\n" unless output.empty? exit 1 if has_errors || (output.any? && PuppetSyntax.fail_on_deprecation_notices) end desc 'Syntax check Puppet templates' task :templates do |t| warn "---> #{t.name}" c = PuppetSyntax::Templates.new result = c.check(filelist_templates) unless result[:warnings].empty? $stdout.puts 'WARNINGS:' $stdout.puts result[:warnings].join("\n") end unless result[:errors].empty? warn 'ERRORS:' warn result[:errors].join("\n") exit 1 end end desc 'Syntax check Hiera config files' task hiera: [ 'syntax:hiera:yaml', ] namespace :hiera do task :yaml do |t| warn "---> #{t.name}" warn "#{t.name} was called, but PuppetSyntax.check_hiera_keys is false. hiera syntax won't be checked" unless PuppetSyntax.check_hiera_keys c = PuppetSyntax::Hiera.new errors = c.check(filelist_hiera_yaml) $stdout.puts "#{errors.join("\n")}\n" unless errors.empty? exit 1 unless errors.empty? end end end end |
Instance Method Details
#filelist(paths) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/puppet-syntax/tasks/puppet-syntax.rb', line 9 def filelist(paths) excludes = PuppetSyntax.exclude_paths excludes.push('pkg/**/*') excludes.push('vendor/**/*') files = FileList[paths] files.reject! { |f| File.directory?(f) } files.exclude(*excludes) end |
#filelist_hiera_yaml ⇒ Object
26 27 28 |
# File 'lib/puppet-syntax/tasks/puppet-syntax.rb', line 26 def filelist_hiera_yaml filelist(PuppetSyntax.hieradata_paths) end |
#filelist_manifests ⇒ Object
18 19 20 |
# File 'lib/puppet-syntax/tasks/puppet-syntax.rb', line 18 def filelist_manifests filelist(PuppetSyntax.manifests_paths) end |
#filelist_templates ⇒ Object
22 23 24 |
# File 'lib/puppet-syntax/tasks/puppet-syntax.rb', line 22 def filelist_templates filelist(PuppetSyntax.templates_paths) end |