Class: R10K::Action::Puppetfile::Check

Inherits:
Base
  • Object
show all
Defined in:
lib/r10k/action/puppetfile/check.rb

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS, Logging::SYSLOG_LEVELS_MAP

Instance Attribute Summary

Attributes inherited from Base

#settings

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Logging

add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Constructor Details

This class inherits a constructor from R10K::Action::Base

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/r10k/action/puppetfile/check.rb', line 10

def call
  options = { basedir: @root }
  options[:overrides] = {}
  options[:overrides][:modules] = { default_ref: @settings.dig(:git, :default_ref) }
  options[:moduledir] = @moduledir if @moduledir
  options[:puppetfile] = @puppetfile if @puppetfile

  loader = R10K::ModuleLoader::Puppetfile.new(**options)
  begin
    loader.load!
    loader.modules.each do |mod|
      if mod.instance_of?(R10K::Module::Git)
        mod.validate_ref_defined
      end
    end
    $stderr.puts _("Syntax OK")
    true
  rescue => e
    $stderr.puts R10K::Errors::Formatting.format_exception(e, @trace)
    false
  end
end