Puppet Function: archive::go_md5
- Defined in:
-
lib/puppet/functions/archive/go_md5.rb
- Function type:
- Ruby 4.x API
Summary
Retrieves and returns specific file's md5 from GoCD server md5 checksum file
Overview
archive::go_md5(String $username, String $password, String[1] $file, Stdlib::HTTPUrl $url) ⇒ String
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
34
35
36
37
38
39
|
# File 'lib/puppet/functions/archive/go_md5.rb', line 9
Puppet::Functions.create_function(:'archive::go_md5') do
dispatch :default_impl do
param 'String', :username
param 'String', :password
param 'String[1]', :file
param 'Stdlib::HTTPUrl', :url
return_type 'String'
end
def default_impl(username, password, file, url)
uri = URI(url)
response = PuppetX::Bodeco::Util.content(uri, username: username, password: password)
checksums = response.split("\n")
line = checksums.find { |x| x =~ %r{#{file}=} }
md5 = line.match(%r{\b[0-9a-f]{5,40}\b}) unless line.nil?
raise("Could not parse md5 from url #{url} response: #{response}") unless md5
md5[0]
end
end
|