Skip to content

Commit

Permalink
Require rest-client 2.x, drop 1.x support code
Browse files Browse the repository at this point in the history
  • Loading branch information
cben committed Sep 24, 2017
1 parent e872f54 commit 5357cc0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion kubeclient.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'webmock', '~> 3.0.1'
spec.add_development_dependency 'vcr'
spec.add_development_dependency 'rubocop', '= 0.49.1'
spec.add_dependency 'rest-client'
spec.add_dependency 'rest-client', '~> 2.0'
spec.add_dependency 'recursive-open-struct', '~> 1.0.4'
spec.add_dependency 'http', '~> 2.2.2'
end
14 changes: 1 addition & 13 deletions lib/kubeclient/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def create_rest_client(path = nil)
user: @auth_options[:username],
password: @auth_options[:password],
open_timeout: @timeouts[:open],
ClientMixin.restclient_read_timeout_option => @timeouts[:read]
read_timeout: @timeouts[:read]
}
RestClient::Resource.new(@api_endpoint.merge(path).to_s, options)
end
Expand Down Expand Up @@ -441,18 +441,6 @@ def api
JSON.parse(response)
end

def self.restclient_read_timeout_option
@restclient_read_timeout_option ||=
# RestClient silently accepts unknown options, so check accessors instead.
if RestClient::Resource.instance_methods.include?(:read_timeout) # rest-client 2.0
:read_timeout
elsif RestClient::Resource.instance_methods.include?(:timeout) # rest-client 1.x
:timeout
else
raise ArgumentError("RestClient doesn't support neither :read_timeout nor :timeout")
end
end

private

def load_entities
Expand Down
14 changes: 5 additions & 9 deletions test/test_kubeclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def test_timeouts_defaults
)
rest_client = client.rest_client
assert_default_open_timeout(rest_client.open_timeout)
assert_equal(60, read_timeout(rest_client))
assert_equal(60, rest_client.read_timeout)
end

def test_timeouts_open
Expand All @@ -799,7 +799,7 @@ def test_timeouts_open
)
rest_client = client.rest_client
assert_equal(10, rest_client.open_timeout)
assert_equal(60, read_timeout(rest_client))
assert_equal(60, rest_client.read_timeout)
end

def test_timeouts_read
Expand All @@ -809,7 +809,7 @@ def test_timeouts_read
)
rest_client = client.rest_client
assert_default_open_timeout(rest_client.open_timeout)
assert_equal(300, read_timeout(rest_client))
assert_equal(300, rest_client.read_timeout)
end

def test_timeouts_both
Expand All @@ -819,7 +819,7 @@ def test_timeouts_both
)
rest_client = client.rest_client
assert_equal(10, rest_client.open_timeout)
assert_equal(300, read_timeout(rest_client))
assert_equal(300, rest_client.read_timeout)
end

def test_timeouts_infinite
Expand All @@ -829,11 +829,7 @@ def test_timeouts_infinite
)
rest_client = client.rest_client
assert_nil(rest_client.open_timeout)
assert_nil(read_timeout(rest_client))
end

def read_timeout(rest_client)
rest_client.send(Kubeclient::ClientMixin.restclient_read_timeout_option)
assert_nil(rest_client.read_timeout)
end

def assert_default_open_timeout(actual)
Expand Down

0 comments on commit 5357cc0

Please sign in to comment.