Skip to content

Commit

Permalink
fix: raise error if file_name is nil
Browse files Browse the repository at this point in the history
fix: raise if non-200 response
  • Loading branch information
zaben903 committed Oct 20, 2022
1 parent 3bfbb79 commit 87468eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/puppet/functions/checkmk/get_agent_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ def version_different?(url, bearer_token, site_name, os_type)
file_name = ''
Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(request) do |response|
file_name = response['content-disposition'][%r{filename="(.*)"\Z}, 1]
case response.code
when '200'
file_name = response['content-disposition'][%r{filename="(.*)"\Z}, 1]
else
raise Puppet::Error, "Failed to check agent package version: { type: #{response.class}, code: #{response.code}, body: #{response.body} }"
end
end
end

Expand Down

0 comments on commit 87468eb

Please sign in to comment.