k8s-client 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8aa26f3a1aea64470085acc814c0cb3fcfbb6354dce4c025400b895c485a370
4
- data.tar.gz: 36c31b0a1d13d7f22c15efbdddca64a6a243034618cd8a1dc5c435a2cfcf8425
3
+ metadata.gz: 9d7cce8f8084f9e3cd235ac55f5df20258050e7187567aa20d1fec847d4a5cf2
4
+ data.tar.gz: 5a7ea616dbf3dbe85fd9482686f97ff2b06d878ad2e86c9dce5956692bed42e9
5
5
  SHA512:
6
- metadata.gz: afca070bae71e534ded84fbf1c0dcfdfd9e3781d7d1939cbf8a025d10aac00679cd35e1409a8b6ac4fbebd7f880244d278c5942203d7a50eb1df2192cd35ba9c
7
- data.tar.gz: 7a7af7c2a520cacf9e893b080d45dfc02572cf544c373b23a544296f655e222a5cbe3d6abe59aea88b4f3d6f801e17a7bda58ddf054eb07f4a07503e173bc345
6
+ metadata.gz: cfed2d41bdd6ce8f36da105f3277327afb2344ad480fdf8e5361c1c0df5826168b2f16546a9db9d76f22460dab09b7a724610e55e72a6c4860569d9938ef28c8
7
+ data.tar.gz: b758e50f969330760d4846c9c42ad899f6d540fd0a475ef78562b86b071d17f3dc85068ffb5e83597957b324861a05ace3622ec46b922c3ab91b8d3cd5e20866
data/k8s-client.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency "recursive-open-struct", "~> 1.1.0"
30
30
  spec.add_runtime_dependency 'hashdiff', '~> 0.3.7'
31
31
  spec.add_runtime_dependency 'jsonpath', '~> 0.9.5'
32
+ spec.add_runtime_dependency 'yajl-ruby', '~> 1.4.0'
32
33
 
33
34
  spec.add_development_dependency "bundler", "~> 1.16"
34
35
  spec.add_development_dependency "rake", "~> 10.0"
@@ -3,6 +3,6 @@
3
3
  module K8s
4
4
  class Client
5
5
  # Updated on releases using semver.
6
- VERSION = "0.6.2"
6
+ VERSION = "0.6.3"
7
7
  end
8
8
  end
data/lib/k8s/client.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'openssl'
4
4
  require 'base64'
5
+ require 'yajl'
5
6
 
6
7
  require 'k8s/api/metav1'
7
8
  require 'k8s/api/version'
@@ -221,28 +221,26 @@ module K8s
221
221
  def watch(labelSelector: nil, fieldSelector: nil, resourceVersion: nil, timeout: nil, namespace: @namespace)
222
222
  method = 'GET'
223
223
  path = path(namespace: namespace)
224
+ parser = Yajl::Parser.new
225
+ parser.on_parse_complete = lambda do |data|
226
+ event = K8s::API::MetaV1::WatchEvent.new(data)
227
+ yield event
228
+ end
224
229
  @transport.request(
225
230
  method: method,
226
231
  path: path,
227
- response_class: K8s::API::MetaV1::List,
232
+ read_timeout: nil,
228
233
  query: make_query(
229
234
  'labelSelector' => selector_query(labelSelector),
230
235
  'fieldSelector' => selector_query(fieldSelector),
231
236
  'resourceVersion' => resourceVersion,
232
- 'watch' => '1'
237
+ 'watch' => '1',
238
+ 'timeoutSeconds' => timeout
233
239
  ),
234
240
  response_block: lambda do |chunk, _, _|
235
- data = JSON.parse(chunk)
236
- event = K8s::API::MetaV1::WatchEvent.new(data)
237
- resourceVersion = event.resource&.metadata&.resourceVersion
238
- yield event
239
- end,
240
- read_timeout: timeout
241
+ parser << chunk
242
+ end
241
243
  )
242
- rescue Excon::Error::Timeout
243
- retry if timeout.nil?
244
-
245
- raise K8s::Error::Timeout.new(method, path, 408, 'timeout')
246
244
  end
247
245
 
248
246
  # @return [Bool]
data/lib/k8s/transport.rb CHANGED
@@ -181,7 +181,7 @@ module K8s
181
181
 
182
182
  case content_type
183
183
  when 'application/json'
184
- response_data = JSON.parse(response.body)
184
+ response_data = Yajl::Parser.parse(response.body)
185
185
 
186
186
  when 'text/plain'
187
187
  response_data = response.body # XXX: broken if status 2xx
@@ -223,8 +223,7 @@ module K8s
223
223
  response = excon.request(**excon_options)
224
224
  t = Time.now - start
225
225
 
226
- obj = parse_response(response, options,
227
- response_class: response_class)
226
+ obj = options[:response_block] ? {} : parse_response(response, options, response_class: response_class)
228
227
  rescue K8s::Error::API => exc
229
228
  logger.warn { "#{format_request(options)} => HTTP #{exc.code} #{exc.reason} in #{'%.3f' % t}s" }
230
229
  logger.debug { "Request: #{excon_options[:body]}" } if excon_options[:body]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k8s-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-23 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.9.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: yajl-ruby
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.4.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.4.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement