kubeclient 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kubeclient might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dec12a4dcb163b81ca8da0db77cf08752f41177a
4
- data.tar.gz: 0a57e47650e7ee368b3d554842a26d982c86896a
3
+ metadata.gz: 9a71f479760bd69996f7b109ee46d8968ed790fa
4
+ data.tar.gz: 600d882545ff5af34501b0c66913cf2f31905d0b
5
5
  SHA512:
6
- metadata.gz: 57fa63930a3ea9e626076806c1ec24528a0f21e1a60fff77f48edb12ea607a7ec2e35b8c5d70912af2a5116e648b7ee9ad531af4a2c99dcb4f5262fb98ba19d3
7
- data.tar.gz: dbab4feff7832d392057430c11301e79ee2d2d3ff827ee471fabb74cb3ef08394579e11c6bd464577f3d36fa838e29c13360bf9307b506c7641cc63cb6de4f61
6
+ metadata.gz: 41a44396960513d8841627506c9fdc9a607bac842d0662f52023a504cba5f06d64783dfc9ef78dd38fb31ecfc78ae37a96708de083253f511898ba96d1f8a47d
7
+ data.tar.gz: cd1cc5c1a512c4f3bf2a1edc52c9f97a54ab562e24522b8702c33628341ce3a649a585b9b2fa955b773a4d48549851e0b05856064ff37c7e5e9ee0dbb553c035
data/README.md CHANGED
@@ -227,6 +227,19 @@ The below example is for v1
227
227
  client.update_service service1
228
228
  ```
229
229
 
230
+ #### Patch an entity (by name)
231
+ For example: `patch_pod`, `patch_service`, `patch_secret`, `patch_resource_quota`, `patch_persistent_volume`
232
+
233
+ Input parameters - name (string) specifying the entity name, patch (hash) to be applied to the resource, optional: namespace name (string)
234
+
235
+ The PATCH request should include the namespace name, except for nodes and namespaces entities.
236
+
237
+ The below example is for v1
238
+
239
+ ```ruby
240
+ client.patch_pod "docker-registry", {:metadata => {:annotations => {:key => 'value'}}}, "default"
241
+ ```
242
+
230
243
  #### Get all entities of all types : all_entities
231
244
  Returns a hash with the following keys (node, secret, service, pod, replication_controller, namespace, resource_quota, limit_range, endpoint, event, persistent_volume, persistent_volume_claim, component_status and service_account). Each key points to an EntityList of same type.
232
245
  This method is a convenience method instead of calling each entity's get method separately.
@@ -109,6 +109,10 @@ module Kubeclient
109
109
  define_method("update_#{entity_name}") do |entity_config|
110
110
  update_entity(entity_type, entity_config)
111
111
  end
112
+
113
+ define_method("patch_#{entity_name}") do |name, patch, namespace = nil|
114
+ patch_entity(entity_type, name, patch, namespace)
115
+ end
112
116
  end
113
117
  end
114
118
 
@@ -243,6 +247,15 @@ module Kubeclient
243
247
  end
244
248
  end
245
249
 
250
+ def patch_entity(entity_type, name, patch, namespace = nil)
251
+ ns_prefix = build_namespace_prefix(namespace)
252
+ @headers['Content-Type'] = 'application/strategic-merge-patch+json'
253
+ handle_exception do
254
+ rest_client[ns_prefix + resource_name(entity_type) + "/#{name}"]
255
+ .patch(patch.to_json, @headers)
256
+ end
257
+ end
258
+
246
259
  def new_entity(hash, klass)
247
260
  klass.new(hash)
248
261
  end
@@ -1,4 +1,4 @@
1
1
  # Kubernetes REST-API Client
2
2
  module Kubeclient
3
- VERSION = '1.1.2'
3
+ VERSION = '1.1.3'
4
4
  end
@@ -0,0 +1,25 @@
1
+ {
2
+ "status" : {},
3
+ "kind" : "Service",
4
+ "apiVersion" : "v1",
5
+ "spec" : {
6
+ "ports" : [
7
+ {
8
+ "targetPort" : 80,
9
+ "nodePort" : 0,
10
+ "port" : 80,
11
+ "protocol" : "TCP"
12
+ }
13
+ ],
14
+ "clusterIP" : "1.2.3.4"
15
+ },
16
+ "metadata" : {
17
+ "name" : "my_service",
18
+ "creationTimestamp" : null,
19
+ "namespace" : "development",
20
+ "resourceVersion" : "2",
21
+ "annotations" : {
22
+ "key" : "value"
23
+ }
24
+ }
25
+ }
@@ -229,4 +229,33 @@ class TestService < MiniTest::Test
229
229
  data['metadata']['namespace'] == 'development'
230
230
  end
231
231
  end
232
+
233
+ def test_patch_service
234
+ service = Kubeclient::Service.new
235
+ name = 'my_service'
236
+
237
+ service.metadata = {}
238
+ service.metadata.name = name
239
+ service.metadata.namespace = 'development'
240
+
241
+ expected_url = "http://localhost:8080/api/v1/namespaces/development/services/#{name}"
242
+ stub_request(:patch, expected_url)
243
+ .to_return(body: open_test_file('service_patch.json'), status: 200)
244
+
245
+ patch = {
246
+ metadata: {
247
+ annotations: {
248
+ key: 'value'
249
+ }
250
+ }
251
+ }
252
+
253
+ client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1'
254
+ client.patch_service name, patch, 'development'
255
+
256
+ assert_requested(:patch, expected_url, times: 1) do |req|
257
+ data = JSON.parse(req.body)
258
+ data['metadata']['annotations']['key'] == 'value'
259
+ end
260
+ end
232
261
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubeclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alissa Bonas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -207,6 +207,7 @@ files:
207
207
  - test/json/service_account_list.json
208
208
  - test/json/service_illegal_json_404.json
209
209
  - test/json/service_list.json
210
+ - test/json/service_patch.json
210
211
  - test/json/service_update.json
211
212
  - test/json/versions_list.json
212
213
  - test/json/watch_stream.json
@@ -290,6 +291,7 @@ test_files:
290
291
  - test/json/service_account_list.json
291
292
  - test/json/service_illegal_json_404.json
292
293
  - test/json/service_list.json
294
+ - test/json/service_patch.json
293
295
  - test/json/service_update.json
294
296
  - test/json/versions_list.json
295
297
  - test/json/watch_stream.json