X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Farchive%2Fmanifests%2Fartifactory.pp;h=3a1171c731ece7cbbe975e0480a768d7c5e41460;hb=b3d748149a3204479e9cb6787a7caf668488d8f8;hp=67eb55d111d4c427edda571313c28a51b559fd75;hpb=ce70d6baf887ae03a2a6a7f5e73eb2e2c3dea208;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/archive/manifests/artifactory.pp b/3rdparty/modules/archive/manifests/artifactory.pp index 67eb55d11..3a1171c73 100644 --- a/3rdparty/modules/archive/manifests/artifactory.pp +++ b/3rdparty/modules/archive/manifests/artifactory.pp @@ -8,7 +8,10 @@ # # * path: fully qualified filepath for the download the file or use archive_path and only supply filename. (namevar). # * ensure: ensure the file is present/absent. -# * url: artifactory download URL. +# * url: artifactory download url filepath. NOTE: replaces server, port, url_path parameters. +# * server: artifactory server name (deprecated). +# * port: artifactory server port (deprecated). +# * url_path: artifactory file path http://{server}:{port}/artifactory/{url_path} (deprecated). # * owner: file owner (see archive params for defaults). # * group: file group (see archive params for defaults). # * mode: file mode (see archive params for defaults). @@ -40,17 +43,20 @@ # } # define archive::artifactory ( - Stdlib::HTTPUrl $url, - String $path = $name, - Enum['present', 'absent'] $ensure = present, - Optional[String] $owner = undef, - Optional[String] $group = undef, - Optional[String] $mode = undef, - Optional[Boolean] $extract = undef, - Optional[String] $extract_path = undef, - Optional[String] $creates = undef, - Optional[Boolean] $cleanup = undef, - Optional[Stdlib::Absolutepath] $archive_path = undef, + String $path = $name, + Enum['present', 'absent'] $ensure = present, + Optional[Pattern[/^https?:\/\//]] $url = undef, + Optional[String] $server = undef, + Optional[Integer] $port = undef, + Optional[String] $url_path = undef, + Optional[String] $owner = undef, + Optional[String] $group = undef, + Optional[String] $mode = undef, + Optional[Boolean] $extract = undef, + Optional[String] $extract_path = undef, + Optional[String] $creates = undef, + Optional[Boolean] $cleanup = undef, + Optional[Stdlib::Compat::Absolute_path] $archive_path = undef, ) { include ::archive::params @@ -61,32 +67,48 @@ define archive::artifactory ( $file_path = $path } - assert_type(Stdlib::Absolutepath, $file_path) |$expected, $actual| { - fail("archive::artifactory[${name}]: \$name or \$archive_path must be '${expected}', not '${actual}'") + if $file_path !~ Stdlib::Compat::Absolute_path { + fail("archive::artifactory[${name}]: \$name or \$archive_path must be an absolute path!") # lint:ignore:trailing_comma } - $maven2_data = archive::parse_artifactory_url($url) - if $maven2_data and $maven2_data['folder_iteg_rev'] == 'SNAPSHOT'{ - # URL represents a SNAPSHOT version. eg 'http://artifactory.example.com/artifactory/repo/com/example/artifact/0.0.1-SNAPSHOT/artifact-0.0.1-SNAPSHOT.zip' - # Only Artifactory Pro lets you download this directly but the corresponding fileinfo endpoint (where the sha1 checksum is published) doesn't exist. - # This means we can't use the artifactory_sha1 function + if $url { + $maven2_data = archive::parse_artifactory_url($url) + if $maven2_data and $maven2_data['folder_iteg_rev'] == 'SNAPSHOT'{ + # URL represents a SNAPSHOT version. eg 'http://artifactory.example.com/artifactory/repo/com/example/artifact/0.0.1-SNAPSHOT/artifact-0.0.1-SNAPSHOT.zip' + # Only Artifactory Pro lets you download this directly but the corresponding fileinfo endpoint (where the sha1 checksum is published) doesn't exist. + # This means we can't use the artifactory_sha1 function - $latest_url_data = archive::artifactory_latest_url($url, $maven2_data) + $latest_url_data = archive::artifactory_latest_url($url, $maven2_data) - $file_url = $latest_url_data['url'] - $sha1 = $latest_url_data['sha1'] + $file_url = $latest_url_data['url'] + $sha1 = $latest_url_data['sha1'] + } else { + $file_url = $url + $sha1_url = regsubst($url, '/artifactory/', '/artifactory/api/storage/') + $sha1 = undef + } + } elsif $server and $port and $url_path { + warning('archive::artifactory attribute: server, port, url_path are deprecated') + $art_url = "http://${server}:${port}/artifactory" + $file_url = "${art_url}/${url_path}" + $sha1_url = "${art_url}/api/storage/${url_path}" + $sha1 = undef } else { - $file_url = $url - $sha1 = archive::artifactory_checksum($url,'sha1') + fail('Please provide fully qualified url path for artifactory file.') } + if $sha1 { + $_sha1 = $sha1 + } else { + $_sha1 = artifactory_sha1($sha1_url) + } archive { $file_path: ensure => $ensure, path => $file_path, extract => $extract, extract_path => $extract_path, source => $file_url, - checksum => $sha1, + checksum => $_sha1, checksum_type => 'sha1', creates => $creates, cleanup => $cleanup,