k8s-client 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/k8s-client +10 -2
- data/lib/k8s/client.rb +1 -4
- data/lib/k8s/client/version.rb +1 -1
- data/lib/k8s/transport.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba459f35445e6a9712b9c13f4aae1a1e64ee54671c2e79312961814e128a8a0
|
4
|
+
data.tar.gz: 645af48b165e0d3993f76dee2f4e0cbf81a9df2175ba6b7faabecf88eb22fc11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 198809fd3961246fe35ac9f8b31bf986573978e1aa60281b38ba53e610f1620c8cefee834f8e12a6a782ea30c0a2ba61d9b660f10d7f3dd0ca28ae6d81f714f6
|
7
|
+
data.tar.gz: 244edac8e01d0896b3b6770f9e414393418aaeb3bc3152154c505f6d5288250b46aef9f0323ece7e74c79738ebb05546f2010bbc4ebfa467cee2847499e9f382
|
data/bin/k8s-client
CHANGED
@@ -36,7 +36,8 @@ Options = Struct.new(
|
|
36
36
|
:api,
|
37
37
|
:list_api_resources,
|
38
38
|
:patch_deployment,
|
39
|
-
:replicas
|
39
|
+
:replicas,
|
40
|
+
:version
|
40
41
|
)
|
41
42
|
|
42
43
|
options = Options.new
|
@@ -63,6 +64,9 @@ opt_parser = OptionParser.new do |parser|
|
|
63
64
|
K8s::Logging.quiet!
|
64
65
|
K8s::Transport.quiet!
|
65
66
|
end
|
67
|
+
parser.on('--version') do
|
68
|
+
options.version = true
|
69
|
+
end
|
66
70
|
parser.on('--in-cluster-config') do
|
67
71
|
options.in_cluster_config = true
|
68
72
|
end
|
@@ -174,7 +178,11 @@ else
|
|
174
178
|
ssl_verify_peer: !options.insecure_skip_tls_verify)
|
175
179
|
end
|
176
180
|
|
177
|
-
|
181
|
+
if options.version
|
182
|
+
logger.info client.version
|
183
|
+
else
|
184
|
+
logger.info "Kube server version: #{client.version.gitVersion}"
|
185
|
+
end
|
178
186
|
|
179
187
|
if options.prefetch_resources
|
180
188
|
client.apis(prefetch_resources: true)
|
data/lib/k8s/client.rb
CHANGED
@@ -60,10 +60,7 @@ module K8s
|
|
60
60
|
# @raise [K8s::Error]
|
61
61
|
# @return [K8s::API::Version]
|
62
62
|
def version
|
63
|
-
@transport.
|
64
|
-
'/version',
|
65
|
-
response_class: K8s::API::Version
|
66
|
-
)
|
63
|
+
@version ||= @transport.version
|
67
64
|
end
|
68
65
|
|
69
66
|
# @param api_version [String] "group/version" or "version" (core)
|
data/lib/k8s/client/version.rb
CHANGED
data/lib/k8s/transport.rb
CHANGED
@@ -22,6 +22,9 @@ module K8s
|
|
22
22
|
'Accept' => 'application/json'
|
23
23
|
}.freeze
|
24
24
|
|
25
|
+
# Min version of Kube API for which delete options need to be sent as request body
|
26
|
+
DELETE_OPTS_BODY_VERSION_MIN = Gem::Version.new('1.11')
|
27
|
+
|
25
28
|
# Construct transport from kubeconfig
|
26
29
|
#
|
27
30
|
# @param config [K8s::Config]
|
@@ -217,6 +220,10 @@ module K8s
|
|
217
220
|
# @param response_class [Class] decode response body using #from_json
|
218
221
|
# @param options [Hash] @see Excon#request
|
219
222
|
def request(response_class: nil, **options)
|
223
|
+
if options[:method] == 'DELETE' && need_delete_body?
|
224
|
+
options[:request_object] = options.delete(:query)
|
225
|
+
end
|
226
|
+
|
220
227
|
excon_options = request_options(**options)
|
221
228
|
|
222
229
|
start = Time.now
|
@@ -282,6 +289,19 @@ module K8s
|
|
282
289
|
objects
|
283
290
|
end
|
284
291
|
|
292
|
+
# @return [K8s::API::Version]
|
293
|
+
def version
|
294
|
+
@version ||= get(
|
295
|
+
'/version',
|
296
|
+
response_class: K8s::API::Version
|
297
|
+
)
|
298
|
+
end
|
299
|
+
|
300
|
+
# @return [true, false] true if delete options should be sent as bode of the DELETE request
|
301
|
+
def need_delete_body?
|
302
|
+
@need_delete_body ||= Gem::Version.new(version.gitVersion.match(/v*(.*)/)[1]) < DELETE_OPTS_BODY_VERSION_MIN
|
303
|
+
end
|
304
|
+
|
285
305
|
# @param path [Array<String>] @see #path
|
286
306
|
# @param options [Hash] @see #request
|
287
307
|
def get(*path, **options)
|
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.
|
4
|
+
version: 0.6.4
|
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
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|