From e872f548e94ef5989d733c2d116bad38ec0b07be Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Mon, 18 Sep 2017 01:16:52 +0300 Subject: [PATCH 1/2] Revert "Test both rest-client 1.8 and latest" This reverts commit 15cd763f1769d4cbbcd7e70dd016139cea8bc0ec. --- .rubocop.yml | 4 +--- .travis.yml | 8 -------- Gemfile-rest-client-1.8.rb | 11 ----------- 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 Gemfile-rest-client-1.8.rb diff --git a/.rubocop.yml b/.rubocop.yml index 30cab513..264438a0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,8 +18,6 @@ Metrics/ModuleLength: Style/MethodCallWithArgsParentheses: Enabled: true IgnoredMethods: [require, raise, include, attr_reader, refute, assert] - Exclude: [Gemfile*, Rakefile, kubeclient.gemspec] -Style/FileName: - Exclude: [Gemfile*] + Exclude: [Gemfile, Rakefile, kubeclient.gemspec] Security/MarshalLoad: Exclude: [test/**/*] diff --git a/.travis.yml b/.travis.yml index e6c6bb10..c9c41725 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,9 @@ rvm: - "2.2" - "2.3.0" - "2.4.0" -gemfile: - - Gemfile - - Gemfile-rest-client-1.8.rb sudo: false cache: bundler script: bundle exec rake $TASK env: - TASK=test - TASK=rubocop -matrix: - exclude: - # No point running rubocop with old rest-client - - gemfile: Gemfile-rest-client-1.8.rb - env: TASK=rubocop diff --git a/Gemfile-rest-client-1.8.rb b/Gemfile-rest-client-1.8.rb deleted file mode 100644 index 1785cc90..00000000 --- a/Gemfile-rest-client-1.8.rb +++ /dev/null @@ -1,11 +0,0 @@ -# For travis to additionally test rest-client 1.x. - -source 'https://rubygems.org' - -# Specify your gem's dependencies in kubeclient.gemspec -gemspec - -if dependencies.any? # needed for overriding with recent bundler (1.13 ?) - dependencies.delete('rest-client') - gem 'rest-client', '= 1.8.0' -end From 5357cc050c67cea2fdd0b87d6e6953ee5a6d6820 Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Mon, 18 Sep 2017 01:13:35 +0300 Subject: [PATCH 2/2] Require rest-client 2.x, drop 1.x support code --- kubeclient.gemspec | 2 +- lib/kubeclient/common.rb | 14 +------------- test/test_kubeclient.rb | 14 +++++--------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/kubeclient.gemspec b/kubeclient.gemspec index e3451147..d996eb58 100644 --- a/kubeclient.gemspec +++ b/kubeclient.gemspec @@ -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 diff --git a/lib/kubeclient/common.rb b/lib/kubeclient/common.rb index 966950fb..887ed52d 100644 --- a/lib/kubeclient/common.rb +++ b/lib/kubeclient/common.rb @@ -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 @@ -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 diff --git a/test/test_kubeclient.rb b/test/test_kubeclient.rb index fa37acce..a76cdefd 100644 --- a/test/test_kubeclient.rb +++ b/test/test_kubeclient.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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)