Module: Ra10ke::Dependencies
- Included in:
- RakeTask
- Defined in:
- lib/ra10ke/dependencies.rb
Defined Under Namespace
Classes: Verification
Constant Summary collapse
- GOOD_EMOJI =
ENV['GOOD_EMOJI'] || '👍'
- BAD_EMOJI =
ENV['BAD_EMOJI'] || '😨'
Instance Method Summary collapse
Instance Method Details
#define_task_dependencies(*_args) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# 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 |
#define_task_print_git_conversion(*_args) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# 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 |