voxpupuli / ra10ke

Rake tasks related to R10K and Puppetfile
https://rubygems.org/gems/ra10ke
MIT License
30 stars 22 forks source link

Converts puppet forge module entries into puppetfile git entries #76

Closed logicminds closed 2 years ago

logicminds commented 2 years ago

Example: bundle exec rake r10k:print_git_conversion

Converts the following

# # In addition to the component modules listed here, the 'site' directory
# # includes 'role' and 'profile' modules. The 'role' module contains
# # Puppet classes that constitute a machine role or business function.
# #
# # Start Forge Modules
# # puppetlabs/windows pack
mod 'puppetlabs/reboot'
mod 'puppetlabs/registry',                 '1.1.4'
mod 'puppetlabs/powershell',               '2.1.0'
mod 'puppetlabs/acl',                      '1.1.2'
mod 'puppetlabs/wsus_client',              '1.0.3'
mod 'puppetlabs/chocolatey',               '3.0.0'
mod 'puppet/download_file',                '2.1.0'
mod 'puppet/windowsfeature',               '2.1.0'
mod 'puppet/windows_env',                  '2.3.0'
mod 'noma4i/windows_updates',              '0.2.2'
mod 'ianoberst/xml_fragment',              '1.0.2'

into

mod 'reboot',
  :git => 'https://github.com/puppetlabs/puppetlabs-reboot',
  :ref => 'v4.1.0'

mod 'registry',
  :git => 'https://github.com/puppetlabs/puppetlabs-registry',
  :ref => '1.1.4'

mod 'powershell',
  :git => 'https://github.com/puppetlabs/puppetlabs-powershell',
  :ref => '2.1.0'

mod 'acl',
  :git => 'https://github.com/puppetlabs/puppetlabs-acl',
  :ref => '1.1.2'

mod 'wsus_client',
  :git => 'https://github.com/puppetlabs/puppetlabs-wsus_client',
  :ref => '1.0.3'

mod 'chocolatey',
  :git => 'https://github.com/puppetlabs/puppetlabs-chocolatey',
  :ref => '3.0.0'

mod 'download_file',
  :git => 'https://github.com/voxpupuli/puppet-download_file',
  :ref => 'v2.1.0'

mod 'windowsfeature',
  :git => 'https://github.com/voxpupuli/puppet-windowsfeature',
  :ref => 'v2.1.0'

mod 'windows_env',
  :git => 'https://github.com/voxpupuli/puppet-windows_env',
  :ref => 'v2.3.0'

mod 'windows_updates',
  :git => 'https://github.com/noma4i/puppet-windows_updates',
  :ref => 'bad url or tag 0.2.2 is missing'

mod 'xml_fragment',
  :git => 'https://github.com/Areson/xml_fragment',
  :ref => 'bad url or tag 1.0.2 is missing'
codecov[bot] commented 2 years ago

Codecov Report

Merging #76 (4bb63a6) into master (0afea64) will increase coverage by 2.24%. The diff coverage is 96.96%.

:exclamation: Current head 4bb63a6 differs from pull request most recent head b488296. Consider uploading reports for the commit b488296 to get more accurate results

@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
+ Coverage   62.89%   65.13%   +2.24%     
==========================================
  Files          12       12              
  Lines         512      545      +33     
==========================================
+ Hits          322      355      +33     
  Misses        190      190              
Impacted Files Coverage Δ
lib/ra10ke/dependencies.rb 91.75% <96.15%> (+1.61%) :arrow_up:
lib/ra10ke.rb 97.67% <100.00%> (+0.05%) :arrow_up:
lib/ra10ke/git_repo.rb 100.00% <100.00%> (+1.92%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update af46a43...b488296. Read the comment docs.

logicminds commented 2 years ago

I need to beef up the tests but was looking for feedback with the output.

This doesn't replace the puppetfile and only provides content to be put into a puppetfile. Which reminds me I need to add some docs around this.

Does the task name look good?

bastelfreak commented 2 years ago

https://forgeapi.puppet.com/#tag/Module-Operations/operation/getModule isn't really helpful :D

logicminds commented 2 years ago

I like the idea and left some minor inline comments. based on the task name I'm not sure if I expect some output or a rewritten Puppetfile. Which would you prefer? I think the task name should reflect that (the description already does). Or maybe offer two tasks, one for rewriting, one for printing?

I have a follow up task to this one that replaces the git urls with internal urls and namespaces. I'll think about the task name a bit. Maybe something with the word print in it.

print_git_format?

bastelfreak commented 2 years ago

https://forgeapi.puppet.com/v3/modules/puppet-borg I think homepage_url maps to project_page from metadata.json. Instead of using homepage_url you should probably use metadata.source?

bastelfreak commented 2 years ago

print_git_format

I think that's a suitable name :+1:

logicminds commented 2 years ago

@bastelfreak I am happy with these changes and my additional test found some edge cases I needed to fix. Ready to merge if you approve.