Module: Berkshelf::RidleyCompatAPI
- Included in:
- RidleyCompat, RidleyCompatJSON, RidleyCompatSimple
- Defined in:
- lib/berkshelf/ridley_compat.rb
Instance Method Summary collapse
Instance Method Details
#get(url) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/berkshelf/ridley_compat.rb', line 25 def get(url) super(url) rescue Net::HTTPExceptions => e case e.response.code when "404" raise Berkshelf::APIClient::ServiceNotFound, "service not found at: #{url}" when /^5/ raise Berkshelf::APIClient::ServiceUnavailable, "service unavailable at: #{url}" else raise Berkshelf::APIClient::BadResponse, "bad response #{e.response}" end rescue Errno::ETIMEDOUT, Timeout::Error raise Berkshelf::APIClient::TimeoutError, "Unable to connect to: #{url}" rescue Errno::EHOSTUNREACH, Errno::ECONNREFUSED => e raise Berkshelf::APIClient::ServiceUnavailable, e end |
#initialize(**opts) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/berkshelf/ridley_compat.rb', line 8 def initialize(**opts) opts = opts.dup opts[:ssl] ||= {} chef_opts = { rest_timeout: opts[:timeout], # opts[:open_timeout] is ignored on purpose headers: opts[:headers], client_name: opts[:client_name], signing_key_filename: opts[:client_key], ssl_verify_mode: opts[:verify] ? :verify_none : :verify_peer, ssl_ca_path: opts[:ssl][:ca_path], ssl_ca_file: opts[:ssl][:ca_file], ssl_client_cert: opts[:ssl][:client_cert], ssl_client_key: opts[:ssl][:client_key], } super(opts[:server_url].to_s, **chef_opts) end |