kubeclient 0.1.6 → 0.1.7
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 +4 -4
- data/README.md +4 -0
- data/Rakefile +2 -2
- data/lib/kubeclient.rb +7 -5
- data/lib/kubeclient/version.rb +1 -1
- data/test/json/empty_pod_list_b3.json +9 -0
- data/test/test_helper.rb +4 -0
- data/test/{kubeclient_test.rb → test_kubeclient.rb} +12 -4
- data/test/{namespace_test.rb → test_namespace.rb} +2 -5
- data/test/{node_test.rb → test_node.rb} +2 -5
- data/test/{pod_test.rb → test_pod.rb} +2 -5
- data/test/{replication_controller_test.rb → test_replication_controller.rb} +2 -5
- data/test/{service_test.rb → test_service.rb} +2 -5
- data/test/{watch_test.rb → test_watch.rb} +2 -5
- metadata +20 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cce5a424d82f97a745e142c887bb3f212e1cb44
|
4
|
+
data.tar.gz: bba2a4ba2dde980a5987d55b7dc16978a371ae29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4095bf9e4a000c1c42ef97aec6bae358decb35943193875003352a3ede9f50e156ad3cb4643d4f7c11d70505c38ad77711763a08b6d1f527a308b29622a3188
|
7
|
+
data.tar.gz: 6d516c2b91b6976cd4eb05f5c72e5044acfa9d8addd12829120628cab787d4911bab04e7cb504cffd4f0e987b4397a3af78337c43f47bd953ee5ec1d216fb5f7
|
data/README.md
CHANGED
@@ -55,6 +55,10 @@ Examples:
|
|
55
55
|
<br>
|
56
56
|
`pods = client.get_pods`
|
57
57
|
<br>
|
58
|
+
You can get entities which have specific labels by specifying input parameter named `labels`: <br>
|
59
|
+
`pods = client.get_pods(labels: 'name=redis-master')` <br>
|
60
|
+
You can specify multiple labels and that returns entities which have both labels: <br>
|
61
|
+
`pods = client.get_pods(labels: 'name=redis-master,app=redis')`
|
58
62
|
|
59
63
|
2. Get a specific node (and respectively: get_service "service id" , get_pod "pod id" , get_replication_controller "rc id" )
|
60
64
|
<br>
|
data/Rakefile
CHANGED
data/lib/kubeclient.rb
CHANGED
@@ -53,11 +53,13 @@ module Kubeclient
|
|
53
53
|
raise KubeException.new(e.http_code, JSON.parse(e.response)['message'])
|
54
54
|
end
|
55
55
|
|
56
|
-
def get_entities(entity_type)
|
57
|
-
|
56
|
+
def get_entities(entity_type, options)
|
57
|
+
params = {}
|
58
|
+
params['labels'] = options[:labels] if options[:labels]
|
59
|
+
|
58
60
|
# TODO: namespace support?
|
59
61
|
response = handling_kube_exception do
|
60
|
-
rest_client[get_resource_name(entity_type)].get
|
62
|
+
rest_client[get_resource_name(entity_type)].get(params: params)
|
61
63
|
end
|
62
64
|
|
63
65
|
result = JSON.parse(response)
|
@@ -165,8 +167,8 @@ module Kubeclient
|
|
165
167
|
entity_name_plural = entity_name.pluralize
|
166
168
|
|
167
169
|
# get all entities of a type e.g. get_nodes, get_pods, etc.
|
168
|
-
define_method("get_#{entity_name_plural}") do
|
169
|
-
get_entities(entity_type)
|
170
|
+
define_method("get_#{entity_name_plural}") do |options = {}|
|
171
|
+
get_entities(entity_type, options)
|
170
172
|
end
|
171
173
|
|
172
174
|
# watch all entities of a type e.g. watch_nodes, watch_pods, etc.
|
data/lib/kubeclient/version.rb
CHANGED
data/test/test_helper.rb
ADDED
@@ -1,7 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'json'
|
3
|
-
require 'webmock/minitest'
|
4
|
-
require './lib/kubeclient'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
def open_test_json_file(name)
|
7
4
|
File.new(File.join(File.dirname(__FILE__), 'json', name))
|
@@ -61,6 +58,17 @@ class KubeClientTest < MiniTest::Test
|
|
61
58
|
assert_instance_of(Service, services[1])
|
62
59
|
end
|
63
60
|
|
61
|
+
def test_empty_list
|
62
|
+
stub_request(:get, /\/pods/)
|
63
|
+
.to_return(body: open_test_json_file('empty_pod_list_b3.json'),
|
64
|
+
status: 200)
|
65
|
+
|
66
|
+
client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
|
67
|
+
pods = client.get_pods
|
68
|
+
assert_instance_of(EntityList, pods)
|
69
|
+
assert_equal(0, pods.size)
|
70
|
+
end
|
71
|
+
|
64
72
|
def test_get_all
|
65
73
|
stub_request(:get, /\/services/)
|
66
74
|
.to_return(body: open_test_json_file('get_all_services_b1.json'),
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'webmock/minitest'
|
3
|
-
require 'json'
|
4
|
-
require './lib/kubeclient'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
# Namespace entity tests
|
7
|
-
class
|
4
|
+
class TestNamespace < MiniTest::Test
|
8
5
|
def test_get_namespace_v1beta3
|
9
6
|
stub_request(:get, /\/namespaces/)
|
10
7
|
.to_return(body: open_test_json_file('namespace_b3.json'),
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'webmock/minitest'
|
3
|
-
require 'json'
|
4
|
-
require './lib/kubeclient'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
# Node entity tests
|
7
|
-
class
|
4
|
+
class TestNode < MiniTest::Test
|
8
5
|
def test_get_from_json_v1
|
9
6
|
stub_request(:get, /\/nodes/)
|
10
7
|
.to_return(body: open_test_json_file('node_b1.json'),
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'webmock/minitest'
|
3
|
-
require 'json'
|
4
|
-
require './lib/kubeclient'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
# Pod entity tests
|
7
|
-
class
|
4
|
+
class TestPod < MiniTest::Test
|
8
5
|
def test_get_from_json_v1
|
9
6
|
stub_request(:get, /\/pods/)
|
10
7
|
.to_return(body: open_test_json_file('pod_b1.json'),
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'webmock/minitest'
|
3
|
-
require './lib/kubeclient'
|
4
|
-
require 'json'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
# Replication Controller entity tests
|
7
|
-
class
|
4
|
+
class TestReplicationController < MiniTest::Test
|
8
5
|
def test_get_from_json_v1
|
9
6
|
stub_request(:get, /\/replicationControllers/)
|
10
7
|
.to_return(body: open_test_json_file('replication_controller_b1.json'),
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'webmock/minitest'
|
3
|
-
require 'json'
|
4
|
-
require './lib/kubeclient'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
# Service entity tests
|
7
|
-
class
|
4
|
+
class TestService < MiniTest::Test
|
8
5
|
def test_get_from_json_v1
|
9
6
|
mock = Service.new(
|
10
7
|
'kind' => 'Service',
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'webmock/minitest'
|
3
|
-
require 'json'
|
4
|
-
require './lib/kubeclient'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
# Watch entity tests
|
7
|
-
class
|
4
|
+
class TestWatch < MiniTest::Test
|
8
5
|
def test_watch_pod_success
|
9
6
|
expected = [
|
10
7
|
{ 'type' => 'ADDED', 'resourceVersion' => '1389' },
|
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.1.
|
4
|
+
version: 0.1.7
|
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-03-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/kubeclient/version.rb
|
158
158
|
- lib/kubeclient/watch_notice.rb
|
159
159
|
- lib/kubeclient/watch_stream.rb
|
160
|
+
- test/json/empty_pod_list_b3.json
|
160
161
|
- test/json/endpoint_list_b3.json
|
161
162
|
- test/json/entity_list_b1.json
|
162
163
|
- test/json/event_list_b3.json
|
@@ -176,13 +177,14 @@ files:
|
|
176
177
|
- test/json/service_b3.json
|
177
178
|
- test/json/service_exception_b1.json
|
178
179
|
- test/json/watch_stream_b3.json
|
179
|
-
- test/
|
180
|
-
- test/
|
181
|
-
- test/
|
182
|
-
- test/
|
183
|
-
- test/
|
184
|
-
- test/
|
185
|
-
- test/
|
180
|
+
- test/test_helper.rb
|
181
|
+
- test/test_kubeclient.rb
|
182
|
+
- test/test_namespace.rb
|
183
|
+
- test/test_node.rb
|
184
|
+
- test/test_pod.rb
|
185
|
+
- test/test_replication_controller.rb
|
186
|
+
- test/test_service.rb
|
187
|
+
- test/test_watch.rb
|
186
188
|
homepage: https://github.com/abonas/kubeclient
|
187
189
|
licenses:
|
188
190
|
- MIT
|
@@ -208,6 +210,7 @@ signing_key:
|
|
208
210
|
specification_version: 4
|
209
211
|
summary: A client for Kubernetes REST api
|
210
212
|
test_files:
|
213
|
+
- test/json/empty_pod_list_b3.json
|
211
214
|
- test/json/endpoint_list_b3.json
|
212
215
|
- test/json/entity_list_b1.json
|
213
216
|
- test/json/event_list_b3.json
|
@@ -227,10 +230,11 @@ test_files:
|
|
227
230
|
- test/json/service_b3.json
|
228
231
|
- test/json/service_exception_b1.json
|
229
232
|
- test/json/watch_stream_b3.json
|
230
|
-
- test/
|
231
|
-
- test/
|
232
|
-
- test/
|
233
|
-
- test/
|
234
|
-
- test/
|
235
|
-
- test/
|
236
|
-
- test/
|
233
|
+
- test/test_helper.rb
|
234
|
+
- test/test_kubeclient.rb
|
235
|
+
- test/test_namespace.rb
|
236
|
+
- test/test_node.rb
|
237
|
+
- test/test_pod.rb
|
238
|
+
- test/test_replication_controller.rb
|
239
|
+
- test/test_service.rb
|
240
|
+
- test/test_watch.rb
|