Sha256: 55a6a90a234f1e8acb5d11f04a0df32188b47249276ab023e86f24309534719c

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

require 'r10k/action/base'
require 'r10k/errors/formatting'
require 'r10k/module_loader/puppetfile'

module R10K
  module Action
    module Puppetfile
      class Check < R10K::Action::Base

        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

        private

        def allowed_initialize_opts
          super.merge(root: :self, puppetfile: :self, moduledir: :self)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
r10k-5.0.0 lib/r10k/action/puppetfile/check.rb
r10k-4.1.0 lib/r10k/action/puppetfile/check.rb
r10k-4.0.2 lib/r10k/action/puppetfile/check.rb
r10k-4.0.1 lib/r10k/action/puppetfile/check.rb
r10k-4.0.0 lib/r10k/action/puppetfile/check.rb
r10k-4.0.0.pre lib/r10k/action/puppetfile/check.rb