From b9d7b465e7445e33e34a7eea4a52dce5859c8579 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 8 Mar 2024 11:58:42 +0100 Subject: [PATCH] Raise warning if hiera check is called but disabled Previously we got the following output from the `syntax` rake task: ```terminal $ bundle exec rake syntax ---> syntax:manifests ---> syntax:templates ---> syntax:hiera:yaml ``` This is a bit misleading because the `syntax:hiera:yaml` task was indeed called, but it doesn't do anything because `PuppetSyntax.check_hiera_keys` was false. With this commit the output changes: ```terminal $ bundle exec rake syntax---> syntax:manifests ---> syntax:templates ---> syntax:hiera:yaml syntax:hiera:yaml was called, but PuppetSyntax.check_hiera_keys is false. hiera syntax won't be checked ``` --- lib/puppet-syntax/tasks/puppet-syntax.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/puppet-syntax/tasks/puppet-syntax.rb b/lib/puppet-syntax/tasks/puppet-syntax.rb index 337e850..9252cae 100644 --- a/lib/puppet-syntax/tasks/puppet-syntax.rb +++ b/lib/puppet-syntax/tasks/puppet-syntax.rb @@ -26,7 +26,7 @@ def filelist_hiera_yaml end def initialize(*_args) - desc 'Syntax check Puppet manifests and templates' + desc 'Syntax check for Puppet manifests, templates and Hiera' task syntax: [ 'syntax:manifests', 'syntax:templates', @@ -69,6 +69,7 @@ def initialize(*_args) 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?