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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9172bf5d56e7437d23e93ba1e6280af446e87282
4
- data.tar.gz: 271517b25926b62222e193e3d722f18a24e1df6b
3
+ metadata.gz: 4cce5a424d82f97a745e142c887bb3f212e1cb44
4
+ data.tar.gz: bba2a4ba2dde980a5987d55b7dc16978a371ae29
5
5
  SHA512:
6
- metadata.gz: 3dca5eb07416265317c30e4e2e35578bdb1d2dc7ea2971df475e295b685dc935e82ea643fdfa503b0d3f30fb0dc9ce0f1983f1bdbe59c912fc097680de52e560
7
- data.tar.gz: 5bdc07a1ed661cb51c5cdf37ef7e410416f44a319707654660d639ab64b1d5c462d483ae4f0152471a9e7be08b11a3151761238cb66b346635f3d9be4a6202a2
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
@@ -4,8 +4,8 @@ require 'rubocop/rake_task'
4
4
 
5
5
  task default: [:test, :rubocop]
6
6
 
7
- task :test do
8
- Dir.glob('./test/*_test.rb').each { |file| require file }
7
+ Rake::TestTask.new do |t|
8
+ t.libs << 'test'
9
9
  end
10
10
 
11
11
  RuboCop::RakeTask.new
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
- # TODO: labels support
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 # nil, labels
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.
@@ -1,4 +1,4 @@
1
1
  # Kubernetes REST-API Client
2
2
  module Kubeclient
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.7'
4
4
  end
@@ -0,0 +1,9 @@
1
+ {
2
+ "kind": "PodList",
3
+ "apiVersion": "v1beta3",
4
+ "metadata": {
5
+ "selfLink": "/api/v1beta3/pods",
6
+ "resourceVersion": "565"
7
+ },
8
+ "items": []
9
+ }
@@ -0,0 +1,4 @@
1
+ require 'minitest/autorun'
2
+ require 'webmock/minitest'
3
+ require 'json'
4
+ require 'kubeclient'
@@ -1,7 +1,4 @@
1
- require 'minitest/autorun'
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 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'json'
4
- require './lib/kubeclient'
1
+ require 'test_helper'
5
2
 
6
3
  # Namespace entity tests
7
- class NamespaceTest < MiniTest::Test
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 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'json'
4
- require './lib/kubeclient'
1
+ require 'test_helper'
5
2
 
6
3
  # Node entity tests
7
- class NodeTest < MiniTest::Test
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 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'json'
4
- require './lib/kubeclient'
1
+ require 'test_helper'
5
2
 
6
3
  # Pod entity tests
7
- class PodTest < MiniTest::Test
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 'minitest/autorun'
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 ReplicationControllerTest < MiniTest::Test
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 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'json'
4
- require './lib/kubeclient'
1
+ require 'test_helper'
5
2
 
6
3
  # Service entity tests
7
- class ServiceTest < MiniTest::Test
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 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'json'
4
- require './lib/kubeclient'
1
+ require 'test_helper'
5
2
 
6
3
  # Watch entity tests
7
- class WatchTest < MiniTest::Test
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.6
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-05 00:00:00.000000000 Z
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/kubeclient_test.rb
180
- - test/namespace_test.rb
181
- - test/node_test.rb
182
- - test/pod_test.rb
183
- - test/replication_controller_test.rb
184
- - test/service_test.rb
185
- - test/watch_test.rb
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/kubeclient_test.rb
231
- - test/namespace_test.rb
232
- - test/node_test.rb
233
- - test/pod_test.rb
234
- - test/replication_controller_test.rb
235
- - test/service_test.rb
236
- - test/watch_test.rb
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