1 # Define: archive::artifactory
2 # ============================
4 # archive wrapper for downloading files from artifactory
9 # * path: fully qualified filepath for the download the file or use archive_path and only supply filename. (namevar).
10 # * ensure: ensure the file is present/absent.
11 # * url: artifactory download URL.
12 # * owner: file owner (see archive params for defaults).
13 # * group: file group (see archive params for defaults).
14 # * mode: file mode (see archive params for defaults).
15 # * archive_path: the parent directory of local filepath.
16 # * extract: whether to extract the files (true/false).
17 # * creates: the file created when the archive is extracted (true/false).
18 # * cleanup: remove archive file after file extraction (true/false).
23 # archive::artifactory { '/tmp/logo.png':
24 # url => 'https://repo.jfrog.org/artifactory/distributions/images/Artifactory_120x75.png',
30 # $dirname = 'gradle-1.0-milestone-4-20110723151213+0300'
31 # $filename = "${dirname}-bin.zip"
33 # archive::artifactory { $filename:
34 # archive_path => '/tmp',
35 # url => "http://repo.jfrog.org/artifactory/distributions/org/gradle/${filename}",
37 # extract_path => '/opt',
38 # creates => "/opt/${dirname}",
42 define archive::artifactory (
45 Enum['present', 'absent'] $ensure = present,
46 Optional[String] $owner = undef,
47 Optional[String] $group = undef,
48 Optional[String] $mode = undef,
49 Optional[Boolean] $extract = undef,
50 Optional[String] $extract_path = undef,
51 Optional[String] $creates = undef,
52 Optional[Boolean] $cleanup = undef,
53 Optional[Stdlib::Absolutepath] $archive_path = undef,
56 include ::archive::params
59 $file_path = "${archive_path}/${name}"
64 assert_type(Stdlib::Absolutepath, $file_path) |$expected, $actual| {
65 fail("archive::artifactory[${name}]: \$name or \$archive_path must be '${expected}', not '${actual}'")
68 $maven2_data = archive::parse_artifactory_url($url)
69 if $maven2_data and $maven2_data['folder_iteg_rev'] == 'SNAPSHOT'{
70 # 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'
71 # Only Artifactory Pro lets you download this directly but the corresponding fileinfo endpoint (where the sha1 checksum is published) doesn't exist.
72 # This means we can't use the artifactory_sha1 function
74 $latest_url_data = archive::artifactory_latest_url($url, $maven2_data)
76 $file_url = $latest_url_data['url']
77 $sha1 = $latest_url_data['sha1']
80 $sha1 = archive::artifactory_checksum($url,'sha1')
87 extract_path => $extract_path,
90 checksum_type => 'sha1',
95 $file_owner = pick($owner, $archive::params::owner)
96 $file_group = pick($group, $archive::params::group)
97 $file_mode = pick($mode, $archive::params::mode)
100 owner => $file_owner,
101 group => $file_group,
103 require => Archive[$file_path],