module Ra10ke::Dependencies
Constants
- BAD_EMOJI
- GOOD_EMOJI
Public Instance Methods
Source
# File lib/ra10ke/dependencies.rb, line 184 def define_task_dependencies(*_args) desc 'Print outdated forge modules' task :dependencies do PuppetForge.user_agent = "ra10ke/#{Ra10ke::VERSION}" puppetfile = get_puppetfile if puppetfile.respond_to? :environment= # Use a fake environment object to reduce log spam and keep :control_branch reference for R10k >= 3.10.0 fake_env = Object.new fake_env.instance_eval do def module_conflicts?(*) false end def name 'test' end def ref :control_branch end end puppetfile.environment = fake_env end PuppetForge.host = puppetfile.forge if /^http/.match?(puppetfile.forge) dependencies = Ra10ke::Dependencies::Verification.new(puppetfile) dependencies.print_table(dependencies.outdated) if dependencies.outdated.any? abort(BAD_EMOJI + ' Not all modules in the Puppetfile are up2date. '.red + BAD_EMOJI) else puts(GOOD_EMOJI + ' All modules in the Puppetfile are up2date. '.green + GOOD_EMOJI) end end end
Source
# File lib/ra10ke/dependencies.rb, line 141 def define_task_print_git_conversion(*_args) desc 'Convert and print forge modules to git format' task :print_git_conversion do require 'ra10ke/git_repo' require 'r10k/puppetfile' require 'puppet_forge' PuppetForge.user_agent = "ra10ke/#{Ra10ke::VERSION}" puppetfile = get_puppetfile puppetfile.load! PuppetForge.host = puppetfile.forge if puppetfile.forge =~ /^http/ # ignore file allows for "don't tell me about this" ignore_modules = [] ignore_modules = File.readlines('.r10kignore').each { |l| l.chomp! } if File.exist?('.r10kignore') forge_mods = puppetfile.modules.find_all do |mod| mod.instance_of?(R10K::Module::Forge) && mod.v3_module.homepage_url? end threads = forge_mods.map do |mod| Thread.new do source_url = mod.v3_module.attributes.dig(:current_release, :metadata, :source) || mod.v3_module.homepage_url # git:// does not work with ls-remote command, convert to https source_url = source_url.gsub('git://', 'https://') source_url = source_url.gsub(/\Agit@(.*):(.*)/) do "https://#{::Regexp.last_match(1)}/#{::Regexp.last_match(2)}" end repo = ::Ra10ke::GitRepo.new(source_url) ref = repo.get_ref_like(mod.expected_version) ref_name = ref ? ref[:name] : "bad url or tag #{mod.expected_version} is missing" <<~EOF mod '#{mod.name}', :git => '#{source_url}', :ref => '#{ref_name}' EOF end end output = threads.map { |th| th.join.value } puts output end end
Source
# File lib/ra10ke/dependencies.rb, line 193 def module_conflicts?(*) false end