Puppet Function: archive::parse_artifactory_url
- Defined in:
- lib/puppet/functions/archive/parse_artifactory_url.rb
- Function type:
- Ruby 4.x API
Overview
A function to parse an Artifactory maven 2 repository URL
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet/functions/archive/parse_artifactory_url.rb', line 4 Puppet::Functions.create_function(:'archive::parse_artifactory_url') do dispatch :parse_artifactory_url do param 'Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]', :url end def parse_artifactory_url(url) # Regex is for the 'maven-2-default Repository Layout' matchdata = url.match(%r{ (?<base_url>.*/artifactory) / (?<repository>[^/]+) / (?<org_path>.+?) / (?<module>[^/]+) / (?<base_rev>[^/]+?) (?:-(?<folder_iteg_rev>SNAPSHOT))? / \k<module>-\k<base_rev> (?:-(?<file_iteg_rev>SNAPSHOT|(?:(?:[0-9]{8}.[0-9]{6})-(?:[0-9]+))))? (?:-(?<classifier>[^/]+?))? \. (?<ext>(?:(?!\d))[^\-/]+|7z) }x) return nil unless matchdata matchdata.names.zip(matchdata.captures).to_h end end |