class Ra10ke::Validate::Validation
Attributes
Public Class Methods
Source
# File lib/ra10ke/validate.rb, line 37 def initialize(file) file ||= './Puppetfile' @puppetfile = File.expand_path(file) abort("Puppetfile does not exist at #{puppetfile}") unless File.readable?(puppetfile) end
Public Instance Methods
Source
# File lib/ra10ke/validate.rb, line 44 def all_modules @all_modules ||= begin r10k_branch = Ra10ke::GitRepo.current_branch(File.dirname(puppetfile)) git_modules(puppetfile).map do |mod| repo = Ra10ke::GitRepo.new(mod[:args][:git]) ref = mod[:args][:ref] || mod[:args][:tag] || mod[:args][:branch] || mod[:args][:commit] # If using control_branch, try to guesstimate what the target branch should be if ref == ':control_branch' ref = ENV['CONTROL_BRANCH'] \ || r10k_branch \ || mod[:args][:default_branch_override] \ || ENV['CONTROL_BRANCH_FALLBACK'] \ || mod[:args][:default_branch] \ || 'main' end valid_ref = repo.valid_ref?(ref) || repo.valid_commit?(mod[:args][:ref]) { name: mod[:name], url: repo.url, ref: ref, valid_url?: repo.valid_url?, valid_ref?: valid_ref, status: valid_ref ? Ra10ke::Validate::GOOD_EMOJI : Ra10ke::Validate::BAD_EMOJI, } end end end
@return [Array] array of module information and git status
Source
# File lib/ra10ke/validate.rb, line 73 def bad_mods? all_modules.find_all { |mod| !mod[:valid_ref?] }.count > 0 end
@return [Boolean] - true if there are any bad mods
Source
# File lib/ra10ke/validate.rb, line 78 def sorted_mods all_modules.sort_by { |a| a[:valid_ref?] ? 1 : 0 } end
@return [Hash] - sorts the mods based on good/bad