Skip to content

Commit

Permalink
stop using RestClient::NotFound so that 0.8.0 works
Browse files Browse the repository at this point in the history
  • Loading branch information
ilackarms committed Aug 2, 2017
1 parent 90887fc commit 6d46d6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
source 'https://rubygems.org'

gem 'json-streamer', :git => "git://github.com/thisismydesign/json-streamer"

# Specify your gem's dependencies in kubeclient.gemspec
gemspec
16 changes: 6 additions & 10 deletions lib/kubeclient/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def handle_exception
{}
end
err_message = json_error_msg['message'] || e.message
error_klass = e.http_code == 404 || e.instance_of?(RestClient::NotFound) ? ResourceNotFoundError : HttpError
error_klass = e.http_code == 404 ? ResourceNotFoundError : HttpError
raise error_klass.new((e.http_code || 404), err_message, e.response)
end

Expand Down Expand Up @@ -250,11 +250,9 @@ def do_rest_request(args)
user: @auth_options[:username],
password: @auth_options[:password],
open_timeout: @timeouts[:open],
ClientMixin.restclient_read_timeout_option => @timeouts[:read],
ClientMixin.restclient_read_timeout_option => @timeouts[:read]
}
if args[:block]
options[:block_response] = args[:block]
end
options[:block_response] = args[:block] if args[:block]
RestClient::Request.execute(options)
end

Expand Down Expand Up @@ -298,7 +296,7 @@ def get_entities(entity_type, klass, resource_name, options = {})
entity_streamer = Json::Streamer::JsonStreamer.new
resource_version_streamer = Json::Streamer::JsonStreamer.new

resource_version_streamer.get(key: "resourceVersion") do |value|
resource_version_streamer.get(key: 'resourceVersion') do |value|
unless resource_version
resource_version = value
end
Expand All @@ -309,16 +307,14 @@ def get_entities(entity_type, klass, resource_name, options = {})
entity_streamer.get(nesting_level: 2, yield_values: false) do |object|
entity = new_entity(object, klass)
if block_given?
yield entity, resource_version
yield(entity, resource_version)
else
entities << entity
end
end

block = proc do |response|
if response.instance_of? Net::HTTPNotFound
raise RestClient::NotFound
end
raise ResourceNotFoundError.new(404, 'Not Found', response) if response.instance_of?(Net::HTTPNotFound)
response.read_body do |chunk|
entity_streamer.parser << chunk
end
Expand Down

0 comments on commit 6d46d6d

Please sign in to comment.