Module: R10K::CLI::Puppetfile::Check

Defined in:
lib/r10k/cli/puppetfile.rb

Class Method Summary collapse

Class Method Details

.commandObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/r10k/cli/puppetfile.rb', line 53

def self.command
  @cmd ||= Cri::Command.define do
    name  'check'
    usage 'check'
    summary 'Try and load the Puppetfile to verify the syntax is correct.'
    run do |opts,args,cmd|
      puppetfile_root = Dir.getwd
      puppetfile_path = ENV['PUPPETFILE_DIR']
      puppetfile      = ENV['PUPPETFILE']

      puppetfile = R10K::Puppetfile.new(puppetfile_root, puppetfile_path, puppetfile)
      begin
        puppetfile.load
      rescue LoadError => ex
        $stderr.puts "ERROR: Puppetfile bad syntax"
        ex.backtrace.each do |line|
            puts line
        end
        exit 1
      end
      exit 0
    end
  end
end