kubeclient 0.2.0 → 0.3.0

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: 45dfb8861491dea98be3173a783b1438c6e4483b
4
- data.tar.gz: fe9da34142a77fe2ac714e99e9498330476b1b00
3
+ metadata.gz: d8b9d95f0fd01cbb76accf474c6526a663f9c579
4
+ data.tar.gz: d2304b7eff799c416993399a15f99de3e2e0a6c2
5
5
  SHA512:
6
- metadata.gz: 2bb7e57ecd253bcd201825abd3d2dbb3714f5b7109046ae04e0eb1fe6248cb7d0d96607bbf3533cf94ddc67d7c31ef6fb8dad2d30a5b9377ed9720d3c5339674
7
- data.tar.gz: 0be89794e620ecd80e112ef8929c0eee1314277db6f8e30a9c053a1bf9db9b587e0f1754e57466b416285fabdb8319d757db6a481d36e06d5e4d9239727ea06c
6
+ metadata.gz: d42a19e312327a1cfa9ade3a6a25a32f9fca63ddcfabcc66d5a888b528316aad59a014481198762eedd4499cbb57849dbbaddc3f68ef8044ed1851199072b9e5
7
+ data.tar.gz: a1e5288ffbf0268e33b5494393b1f77274e8755a580c63c219b9cf57cf5c5a31b4415cff201e4aa0d4dbeac418b0d69b2c69c36791d7d57b37c73d479ab0a65e
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Dependency Status](https://gemnasium.com/abonas/kubeclient.svg)](https://gemnasium.com/abonas/kubeclient)
7
7
 
8
8
  A Ruby client for Kubernetes REST api.
9
- The client supports GET, POST, PUT, DELETE on nodes, pods, services, replication controllers, namespaces and endpoints.
9
+ The client supports GET, POST, PUT, DELETE on nodes, pods, secrets, services, replication controllers, namespaces and endpoints.
10
10
  The client currently supports Kubernetes REST api version v1beta3.
11
11
 
12
12
  ## Installation
@@ -118,7 +118,7 @@ client = Kubeclient::Client.new 'https://localhost:8443/api/' , 'v1beta3',
118
118
  ## Examples:
119
119
 
120
120
  #### Get all instances of a specific entity type
121
- Such as: `get_pods`, `get_services`, `get_nodes`, `get_replication_controllers`
121
+ Such as: `get_pods`, `get_secrets`, `get_services`, `get_nodes`, `get_replication_controllers`
122
122
 
123
123
  ```ruby
124
124
  pods = client.get_pods
@@ -134,7 +134,7 @@ pods = client.get_pods(label_selector: 'name=redis-master,app=redis')
134
134
  ```
135
135
 
136
136
  #### Get a specific instance of an entity (by name)
137
- Such as: `get_service "service name"` , `get_pod "pod name"` , `get_replication_controller "rc name"`
137
+ Such as: `get_service "service name"` , `get_pod "pod name"` , `get_replication_controller "rc name"`, `get_secret "secret name"`
138
138
 
139
139
  The GET request should include the namespace name, except for nodes and namespaces entities.
140
140
 
@@ -151,7 +151,7 @@ Querying with uid causes 404.
151
151
 
152
152
  #### Delete an entity (by name)
153
153
 
154
- For example: `delete_pod "pod name"` , `delete_replication_controller "rc name"`, `delete node "node name"`
154
+ For example: `delete_pod "pod name"` , `delete_replication_controller "rc name"`, `delete_node "node name"`, `delete_secret "secret name"`
155
155
 
156
156
  Input parameter - name (string) specifying service name, pod name, replication controller name.
157
157
  ```ruby
@@ -159,7 +159,7 @@ client.delete_service "redis-service"
159
159
  ```
160
160
 
161
161
  #### Create an entity
162
- For example: `create_pod pod_object`, `create_replication_controller rc_obj`
162
+ For example: `create_pod pod_object`, `create_replication_controller rc_obj`, `create_secret secret_object`
163
163
 
164
164
  Input parameter - object of type `Service`, `Pod`, `ReplicationController`.
165
165
 
@@ -177,7 +177,7 @@ client.create_service service`
177
177
  ```
178
178
 
179
179
  #### Update an entity
180
- For example: `update_pod`, `update_service`, `update_replication_controller`
180
+ For example: `update_pod`, `update_service`, `update_replication_controller`, `update_secret`
181
181
 
182
182
  Input parameter - object of type `Service`, `Pod`, `ReplicationController`
183
183
 
@@ -188,7 +188,7 @@ client.update_service service1
188
188
  ```
189
189
 
190
190
  #### Get all entities of all types : all_entities
191
- Returns a hash with 7 keys (node, service, pod, replication_controller, namespace, endpoint and event). Each key points to an EntityList of same type.
191
+ Returns a hash with 8 keys (node, secret, service, pod, replication_controller, namespace, endpoint and event). Each key points to an EntityList of same type.
192
192
 
193
193
  This method is a convenience method instead of calling each entity's get method separately.
194
194
 
@@ -19,7 +19,7 @@ module Kubeclient
19
19
  # manually on every new entity addition,
20
20
  # and especially since currently the class body is empty
21
21
  ENTITY_TYPES = %w(Pod Service ReplicationController Node Event Endpoint
22
- Namespace).map do |et|
22
+ Namespace Secret).map do |et|
23
23
  clazz = Class.new(RecursiveOpenStruct) do
24
24
  def initialize(hash = nil, args = {})
25
25
  args.merge!(recurse_over_arrays: true)
@@ -1,4 +1,4 @@
1
1
  # Kubernetes REST-API Client
2
2
  module Kubeclient
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
@@ -0,0 +1,16 @@
1
+ {
2
+ "kind": "Secret",
3
+ "apiVersion": "v1",
4
+ "metadata": {
5
+ "name": "test-secret",
6
+ "namespace": "dev",
7
+ "selfLink": "/api/v1/namespaces/dev/secrets/test-secret",
8
+ "uid": "4e38a198-2bcb-11e5-a483-0e840567604d",
9
+ "resourceVersion": "245569",
10
+ "creationTimestamp": "2015-07-16T14:59:49Z"
11
+ },
12
+ "data": {
13
+ "super-secret": "Y2F0J3MgYXJlIGF3ZXNvbWUK"
14
+ },
15
+ "type": "Opaque"
16
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "kind": "SecretList",
3
+ "apiVersion":"v1beta3",
4
+ "metadata":{
5
+ "selfLink":"/api/v1beta3/secrets",
6
+ "resourceVersion":"256788"
7
+ },
8
+ "items": [
9
+ {
10
+ "metadata": {
11
+ "name":"default-token-my2pi",
12
+ "namespace":"default",
13
+ "selfLink":"/api/v1beta3/namespaces/default/secrets/default-token-my2pi",
14
+ "uid":"07b60654-2a65-11e5-a483-0e840567604d",
15
+ "resourceVersion":"11",
16
+ "creationTimestamp":"2015-07-14T20:15:11Z",
17
+ "annotations": {
18
+ "kubernetes.io/service-account.name":"default",
19
+ "kubernetes.io/service-account.uid":"07b350a0-2a65-11e5-a483-0e840567604d"
20
+ }
21
+ },
22
+ "data":{
23
+ "ca.crt":"Y2F0J3MgYXJlIGF3ZXNvbWUK",
24
+ "token":"Y2F0J3MgYXJlIGF3ZXNvbWUK"
25
+ },
26
+ "type":"kubernetes.io/service-account-token"
27
+ },
28
+ {
29
+ "metadata": {
30
+ "name": "test-secret",
31
+ "namespace": "dev",
32
+ "selfLink": "/api/v1beta3/namespaces/dev/secrets/test-secret",
33
+ "uid": "4e38a198-2bcb-11e5-a483-0e840567604d",
34
+ "resourceVersion": "245569",
35
+ "creationTimestamp": "2015-07-16T14:59:49Z"
36
+ },
37
+ "data": {
38
+ "super-secret": "Y2F0J3MgYXJlIGF3ZXNvbWUK"
39
+ },
40
+ "type": "Opaque"
41
+ }
42
+ ]
43
+ }
44
+
@@ -215,9 +215,13 @@ class KubeClientTest < MiniTest::Test
215
215
  .to_return(body: open_test_json_file('namespace_list_b3.json'),
216
216
  status: 200)
217
217
 
218
+ stub_request(:get, %r{/secrets})
219
+ .to_return(body: open_test_json_file('secret_list_b3.json'),
220
+ status: 200)
221
+
218
222
  client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
219
223
  result = client.all_entities
220
- assert_equal(7, result.keys.size)
224
+ assert_equal(8, result.keys.size)
221
225
  assert_instance_of(Kubeclient::Common::EntityList, result['node'])
222
226
  assert_instance_of(Kubeclient::Common::EntityList, result['service'])
223
227
  assert_instance_of(Kubeclient::Common::EntityList,
@@ -225,11 +229,13 @@ class KubeClientTest < MiniTest::Test
225
229
  assert_instance_of(Kubeclient::Common::EntityList, result['pod'])
226
230
  assert_instance_of(Kubeclient::Common::EntityList, result['event'])
227
231
  assert_instance_of(Kubeclient::Common::EntityList, result['namespace'])
232
+ assert_instance_of(Kubeclient::Common::EntityList, result['secret'])
228
233
  assert_instance_of(Kubeclient::Service, result['service'][0])
229
234
  assert_instance_of(Kubeclient::Node, result['node'][0])
230
235
  assert_instance_of(Kubeclient::Event, result['event'][0])
231
236
  assert_instance_of(Kubeclient::Endpoint, result['endpoint'][0])
232
237
  assert_instance_of(Kubeclient::Namespace, result['namespace'][0])
238
+ assert_instance_of(Kubeclient::Secret, result['secret'][0])
233
239
  end
234
240
 
235
241
  def test_api_bearer_token_with_params_success
@@ -0,0 +1,58 @@
1
+ require 'test_helper'
2
+
3
+ # Namespace entity tests
4
+ class TestSecret < MiniTest::Test
5
+ def test_get_secret_v1
6
+ stub_request(:get, %r{/secrets})
7
+ .to_return(body: open_test_json_file('created_secret.json'),
8
+ status: 200)
9
+
10
+ client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1'
11
+ secret = client.get_secret 'test-secret', 'dev'
12
+
13
+ assert_instance_of(Kubeclient::Secret, secret)
14
+ assert_equal('4e38a198-2bcb-11e5-a483-0e840567604d', secret.metadata.uid)
15
+ assert_equal('test-secret', secret.metadata.name)
16
+ assert_equal('v1', secret.apiVersion)
17
+ assert_equal('Y2F0J3MgYXJlIGF3ZXNvbWUK', secret.data['super-secret'])
18
+
19
+ assert_requested(:get,
20
+ 'http://localhost:8080/api/v1/namespaces/dev/secrets/test-secret',
21
+ times: 1)
22
+ end
23
+
24
+ def test_delete_secret_v1
25
+ stub_request(:delete, %r{/secrets})
26
+ .to_return(status: 200)
27
+
28
+ client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1'
29
+ client.delete_secret 'test-secret', 'dev'
30
+
31
+ assert_requested(:delete,
32
+ 'http://localhost:8080/api/v1/namespaces/dev/secrets/test-secret',
33
+ times: 1)
34
+ end
35
+
36
+ def test_create_secret_v1
37
+ stub_request(:post, %r{/secrets})
38
+ .to_return(body: open_test_json_file('created_secret.json'),
39
+ status: 201)
40
+
41
+ secret = Kubeclient::Secret.new
42
+ secret.metadata = {}
43
+ secret.metadata.name = 'test-secret'
44
+ secret.metadata.namespace = 'dev'
45
+ secret.data = {}
46
+ secret.data['super-secret'] = 'Y2F0J3MgYXJlIGF3ZXNvbWUK'
47
+
48
+ client = Kubeclient::Client.new 'http://localhost:8080/api/'
49
+ created_secret = client.create_secret secret
50
+ assert_instance_of(Kubeclient::Secret, created_secret)
51
+ assert_equal(secret.metadata.name, created_secret.metadata.name)
52
+ assert_equal(secret.metadata.namespace, created_secret.metadata.namespace)
53
+ assert_equal(
54
+ secret.data['super-secret'],
55
+ created_secret.data['super-secret']
56
+ )
57
+ end
58
+ 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: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alissa Bonas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-14 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,6 +159,7 @@ files:
159
159
  - lib/kubeclient/watch_notice.rb
160
160
  - lib/kubeclient/watch_stream.rb
161
161
  - test/json/created_namespace_b3.json
162
+ - test/json/created_secret.json
162
163
  - test/json/created_service_b3.json
163
164
  - test/json/empty_pod_list_b3.json
164
165
  - test/json/endpoint_list_b3.json
@@ -173,6 +174,7 @@ files:
173
174
  - test/json/pod_list_b3.json
174
175
  - test/json/replication_controller_b3.json
175
176
  - test/json/replication_controller_list_b3.json
177
+ - test/json/secret_list_b3.json
176
178
  - test/json/service_b3.json
177
179
  - test/json/service_illegal_json_404.json
178
180
  - test/json/service_list_b3.json
@@ -185,6 +187,7 @@ files:
185
187
  - test/test_node.rb
186
188
  - test/test_pod.rb
187
189
  - test/test_replication_controller.rb
190
+ - test/test_secret.rb
188
191
  - test/test_service.rb
189
192
  - test/test_watch.rb
190
193
  - test/valid_token_file
@@ -214,6 +217,7 @@ specification_version: 4
214
217
  summary: A client for Kubernetes REST api
215
218
  test_files:
216
219
  - test/json/created_namespace_b3.json
220
+ - test/json/created_secret.json
217
221
  - test/json/created_service_b3.json
218
222
  - test/json/empty_pod_list_b3.json
219
223
  - test/json/endpoint_list_b3.json
@@ -228,6 +232,7 @@ test_files:
228
232
  - test/json/pod_list_b3.json
229
233
  - test/json/replication_controller_b3.json
230
234
  - test/json/replication_controller_list_b3.json
235
+ - test/json/secret_list_b3.json
231
236
  - test/json/service_b3.json
232
237
  - test/json/service_illegal_json_404.json
233
238
  - test/json/service_list_b3.json
@@ -240,6 +245,7 @@ test_files:
240
245
  - test/test_node.rb
241
246
  - test/test_pod.rb
242
247
  - test/test_replication_controller.rb
248
+ - test/test_secret.rb
243
249
  - test/test_service.rb
244
250
  - test/test_watch.rb
245
251
  - test/valid_token_file