kubeclient 0.1.8 → 0.1.9

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: be8f06e6c46d5f6e8f202ff4f0b36d6474649b45
4
- data.tar.gz: 678a768f43fab92d1e5368da223fb6a8f193b628
3
+ metadata.gz: 44f9ae79ede59af09899f793e1ed033432e53961
4
+ data.tar.gz: 91bd146bc7163d9b63ef077d36282c3f3d4d6e31
5
5
  SHA512:
6
- metadata.gz: 6195902eb2f834c05346d9c6b8f8c200fd44e253451fb9b376486325804d700eddb50d7e35fdb4ba3e5ae48e338db4fea7e6ad156ca84e0033ba1723a7b550b5
7
- data.tar.gz: ec74ebf40164b703d4442c3c77fd715ce1f662392e76ef4bc7ac448ae5a76f5937313dd5503fb361c03e1970b4576ef5776e4e3c8e6e37a871481db18c03d323
6
+ metadata.gz: a228a944f9d2ef70578ab7ad97b5ed1a0636b8b2bcc9e3553d18e5a97c064d2f4135e0803babcf3774e4c020d9ebeb199a0179fa8725ab53e6c91c7bb4a283ac
7
+ data.tar.gz: b770ad33ad96267dbea66d3cd6e3bff15968dd91c2f1f9a540bcc96936762264667c8ea1f19c186c68ba7b017a077dbedf43b2ebef3ea0cd61729080bf14d021
data/README.md CHANGED
@@ -30,9 +30,9 @@ Or install it yourself as:
30
30
  Initialize the client: <br>
31
31
  `client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta3"`
32
32
 
33
- or for the v3:
33
+ Or without specifying version (it will be set by default to "v1beta3"
34
34
 
35
- `client = Kubeclient::Client.new 'http://localhost:8080/api/' , "v1beta3"`
35
+ `client = Kubeclient::Client.new 'http://localhost:8080/api/' `
36
36
 
37
37
  Another option is to initialize the client with URI object:
38
38
 
@@ -101,7 +101,7 @@ The below example is for v1beta3 <br>
101
101
 
102
102
  6. all_entities - Returns a hash with 7 keys (node, service, pod, replication_controller, namespace, endpoint and event). Each key points to an EntityList of same type. This method
103
103
  is a convenience method instead of calling each entity's get method separately. <br>
104
- `client.get_all_entities`
104
+ `client.all_entities`
105
105
 
106
106
  7. Receive entity updates <br>
107
107
  It is possible to receive live update notices watching the relevant entities:
data/lib/kubeclient.rb CHANGED
@@ -6,10 +6,11 @@ require 'kubeclient/entity_list'
6
6
  require 'kubeclient/kube_exception'
7
7
  require 'kubeclient/watch_notice'
8
8
  require 'kubeclient/watch_stream'
9
+ require 'kubeclient/common'
9
10
 
10
11
  module Kubeclient
11
12
  # Kubernetes Client
12
- class Client
13
+ class Client < Common::Client
13
14
  attr_reader :api_endpoint
14
15
 
15
16
  # Dynamically creating classes definitions (class Pod, class Service, etc.),
@@ -23,186 +24,13 @@ module Kubeclient
23
24
  end
24
25
 
25
26
  def initialize(uri, version = 'v1beta3')
26
- @api_endpoint = (uri.is_a? URI) ? uri : URI.parse(uri)
27
- @api_endpoint.path = '/api/' if @api_endpoint.path.empty?
28
- unless @api_endpoint.path.end_with? '/'
29
- @api_endpoint.path = @api_endpoint.path + '/'
30
- end
27
+ handle_uri(uri, '/api')
31
28
  @api_version = version
32
29
  ssl_options
33
30
  end
34
31
 
35
- def rest_client
36
- @rest_client ||= begin
37
- options = {
38
- ssl_ca_file: @ssl_options[:ca_file],
39
- verify_ssl: @ssl_options[:verify_ssl],
40
- ssl_client_cert: @ssl_options[:client_cert],
41
- ssl_client_key: @ssl_options[:client_key]
42
- }
43
- endpoint_with_version = @api_endpoint
44
- .merge("#{@api_endpoint.path}#{@api_version}")
45
- RestClient::Resource.new(endpoint_with_version, options)
46
- end
47
- end
48
-
49
- private
50
-
51
- def handle_exception
52
- yield
53
- rescue RestClient::Exception => e
54
- begin
55
- err_message = JSON.parse(e.response)['message']
56
- rescue JSON::ParserError
57
- err_message = e.message
58
- end
59
- raise KubeException.new(e.http_code, err_message)
60
- end
61
-
62
- def get_entities(entity_type, klass, options)
63
- params = {}
64
- if options[:label_selector]
65
- params['label-selector'] = options[:label_selector]
66
- end
67
-
68
- # TODO: namespace support?
69
- response = handle_exception do
70
- rest_client[get_resource_name(entity_type)].get(params: params)
71
- end
72
-
73
- result = JSON.parse(response)
74
-
75
- resource_version = result.fetch('resourceVersion', nil)
76
- if resource_version.nil?
77
- resource_version =
78
- result.fetch('metadata', {}).fetch('resourceVersion', nil)
79
- end
80
-
81
- collection = result['items'].map { |item| new_entity(item, klass) }
82
-
83
- EntityList.new(entity_type, resource_version, collection)
84
- end
85
-
86
- def watch_entities(entity_type, resource_version = nil)
87
- resource_name = get_resource_name(entity_type.to_s)
88
-
89
- uri = @api_endpoint
90
- .merge("#{@api_endpoint.path}#{@api_version}/watch/" \
91
- "#{resource_name}")
92
-
93
- unless resource_version.nil?
94
- uri.query = URI.encode_www_form('resourceVersion' => resource_version)
95
- end
96
-
97
- options = {
98
- use_ssl: uri.scheme == 'https',
99
- ca_file: @ssl_options[:ca_file],
100
- verify_ssl: @ssl_options[:verify_ssl],
101
- client_cert: @ssl_options[:client_cert],
102
- client_key: @ssl_options[:client_key]
103
- }
104
-
105
- WatchStream.new(uri, options)
106
- end
107
-
108
- def get_entity(entity_type, klass, id)
109
- response = handle_exception do
110
- rest_client[get_resource_name(entity_type) + "/#{id}"].get
111
- end
112
- result = JSON.parse(response)
113
- new_entity(result, klass)
114
- end
115
-
116
- def delete_entity(entity_type, id)
117
- handle_exception do
118
- rest_client[get_resource_name(entity_type) + "/#{id}"].delete
119
- end
120
- end
121
-
122
- def create_entity(entity_type, entity_config)
123
- # to_hash should be called because of issue #9 in recursive open
124
- # struct
125
- hash = entity_config.to_hash
126
- handle_exception do
127
- rest_client[get_resource_name(entity_type)].post(hash.to_json)
128
- end
129
- end
130
-
131
- def update_entity(entity_type, entity_config)
132
- id = entity_config.id
133
- # to_hash should be called because of issue #9 in recursive open
134
- # struct
135
- hash = entity_config.to_hash
136
- # TODO: temporary solution to delete id till this issue is solved
137
- # https://github.com/GoogleCloudPlatform/kubernetes/issues/3085
138
- hash.delete(:id)
139
- handle_exception do
140
- rest_client[get_resource_name(entity_type) + "/#{id}"].put(hash.to_json)
141
- end
142
- end
143
-
144
- protected
145
-
146
- def new_entity(hash, klass)
147
- klass.new(hash)
148
- end
149
-
150
- def get_resource_name(entity_type)
151
- entity_type.pluralize.downcase
152
- end
153
-
154
- public
155
-
156
- def ssl_options(client_cert: nil, client_key: nil, ca_file: nil,
157
- verify_ssl: OpenSSL::SSL::VERIFY_PEER)
158
- @ssl_options = {
159
- ca_file: ca_file,
160
- verify_ssl: verify_ssl,
161
- client_cert: client_cert,
162
- client_key: client_key
163
- }
164
- end
165
-
166
- ENTITY_TYPES.each do |klass, entity_type|
167
- entity_name = entity_type.underscore
168
- entity_name_plural = entity_name.pluralize
169
-
170
- # get all entities of a type e.g. get_nodes, get_pods, etc.
171
- define_method("get_#{entity_name_plural}") do |options = {}|
172
- get_entities(entity_type, klass, options)
173
- end
174
-
175
- # watch all entities of a type e.g. watch_nodes, watch_pods, etc.
176
- define_method("watch_#{entity_name_plural}") do |resource_version = nil|
177
- watch_entities(entity_type, resource_version)
178
- end
179
-
180
- # get a single entity of a specific type by id
181
- define_method("get_#{entity_name}") do |id|
182
- get_entity(entity_type, klass, id)
183
- end
184
-
185
- define_method("delete_#{entity_name}") do |id|
186
- delete_entity(entity_type, id)
187
- end
188
-
189
- define_method("create_#{entity_name}") do |entity_config|
190
- create_entity(entity_type, entity_config)
191
- end
192
-
193
- define_method("update_#{entity_name}") do |entity_config|
194
- update_entity(entity_type, entity_config)
195
- end
196
- end
197
-
198
32
  def all_entities
199
- ENTITY_TYPES.each_with_object({}) do |(_, entity_type), result_hash|
200
- # method call for get each entities
201
- # build hash of entity name to array of the entities
202
- method_name = "get_#{entity_type.underscore.pluralize}"
203
- key_name = entity_type.underscore
204
- result_hash[key_name] = send(method_name)
205
- end
33
+ retrieve_all_entities(ENTITY_TYPES)
206
34
  end
207
35
 
208
36
  def api
@@ -216,5 +44,7 @@ module Kubeclient
216
44
  result = api
217
45
  result.is_a?(Hash) && result['versions'].is_a?(Array)
218
46
  end
47
+
48
+ define_entity_methods(ENTITY_TYPES)
219
49
  end
220
50
  end
@@ -0,0 +1,191 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+ module Kubeclient
4
+ module Common
5
+ # Common methods
6
+ class Client
7
+ def handle_exception
8
+ yield
9
+ rescue RestClient::Exception => e
10
+ begin
11
+ err_message = JSON.parse(e.response)['message']
12
+ rescue JSON::ParserError
13
+ err_message = e.message
14
+ end
15
+ raise KubeException.new(e.http_code, err_message)
16
+ end
17
+
18
+ def handle_uri(uri, path)
19
+ @api_endpoint = (uri.is_a? URI) ? uri : URI.parse(uri)
20
+ @api_endpoint.path = path if @api_endpoint.path.empty?
21
+ @api_endpoint.path = @api_endpoint.path.chop \
22
+ if @api_endpoint.path.end_with? '/'
23
+ end
24
+
25
+ public
26
+
27
+ def self.define_entity_methods(entity_types)
28
+ entity_types.each do |klass, entity_type|
29
+ entity_name = entity_type.underscore
30
+ entity_name_plural = entity_name.pluralize
31
+
32
+ # get all entities of a type e.g. get_nodes, get_pods, etc.
33
+ define_method("get_#{entity_name_plural}") do |options = {}|
34
+ get_entities(entity_type, klass, options)
35
+ end
36
+
37
+ # watch all entities of a type e.g. watch_nodes, watch_pods, etc.
38
+ define_method("watch_#{entity_name_plural}") \
39
+ do |resource_version = nil|
40
+ watch_entities(entity_type, resource_version)
41
+ end
42
+
43
+ # get a single entity of a specific type by id
44
+ define_method("get_#{entity_name}") do |id|
45
+ get_entity(entity_type, klass, id)
46
+ end
47
+
48
+ define_method("delete_#{entity_name}") do |id|
49
+ delete_entity(entity_type, id)
50
+ end
51
+
52
+ define_method("create_#{entity_name}") do |entity_config|
53
+ create_entity(entity_type, entity_config)
54
+ end
55
+
56
+ define_method("update_#{entity_name}") do |entity_config|
57
+ update_entity(entity_type, entity_config)
58
+ end
59
+ end
60
+ end
61
+
62
+ def rest_client
63
+ @rest_client ||= begin
64
+ options = {
65
+ ssl_ca_file: @ssl_options[:ca_file],
66
+ verify_ssl: @ssl_options[:verify_ssl],
67
+ ssl_client_cert: @ssl_options[:client_cert],
68
+ ssl_client_key: @ssl_options[:client_key]
69
+ }
70
+ endpoint_with_version = @api_endpoint.merge(@api_endpoint.path + '/' \
71
+ + @api_version)
72
+ RestClient::Resource.new(endpoint_with_version, options)
73
+ end
74
+ end
75
+
76
+ def watch_entities(entity_type, resource_version = nil)
77
+ resource_name = get_resource_name(entity_type.to_s)
78
+
79
+ uri = @api_endpoint.merge(@api_endpoint.path + '/' + @api_version \
80
+ + '/watch/' + resource_name)
81
+
82
+ unless resource_version.nil?
83
+ uri.query = URI.encode_www_form('resourceVersion' => resource_version)
84
+ end
85
+
86
+ options = {
87
+ use_ssl: uri.scheme == 'https',
88
+ ca_file: @ssl_options[:ca_file],
89
+ verify_ssl: @ssl_options[:verify_ssl],
90
+ client_cert: @ssl_options[:client_cert],
91
+ client_key: @ssl_options[:client_key]
92
+ }
93
+
94
+ WatchStream.new(uri, options)
95
+ end
96
+
97
+ def get_entities(entity_type, klass, options)
98
+ params = {}
99
+ if options[:label_selector]
100
+ params['label-selector'] = options[:label_selector]
101
+ end
102
+
103
+ # TODO: namespace support?
104
+ response = handle_exception do
105
+ rest_client[get_resource_name(entity_type)].get(params: params)
106
+ end
107
+
108
+ result = JSON.parse(response)
109
+
110
+ resource_version = result.fetch('resourceVersion', nil)
111
+ if resource_version.nil?
112
+ resource_version =
113
+ result.fetch('metadata', {}).fetch('resourceVersion', nil)
114
+ end
115
+
116
+ collection = result['items'].map { |item| new_entity(item, klass) }
117
+
118
+ EntityList.new(entity_type, resource_version, collection)
119
+ end
120
+
121
+ def get_entity(entity_type, klass, id)
122
+ response = handle_exception do
123
+ rest_client[get_resource_name(entity_type) + "/#{id}"].get
124
+ end
125
+ result = JSON.parse(response)
126
+ new_entity(result, klass)
127
+ end
128
+
129
+ def delete_entity(entity_type, id)
130
+ handle_exception do
131
+ rest_client[get_resource_name(entity_type) + "/#{id}"].delete
132
+ end
133
+ end
134
+
135
+ def create_entity(entity_type, entity_config)
136
+ # to_hash should be called because of issue #9 in recursive open
137
+ # struct
138
+ hash = entity_config.to_hash
139
+ handle_exception do
140
+ rest_client[get_resource_name(entity_type)].post(hash.to_json)
141
+ end
142
+ end
143
+
144
+ def update_entity(entity_type, entity_config)
145
+ id = entity_config.id
146
+ # to_hash should be called because of issue #9 in recursive open
147
+ # struct
148
+ hash = entity_config.to_hash
149
+ # TODO: temporary solution to delete id till this issue is solved
150
+ # https://github.com/GoogleCloudPlatform/kubernetes/issues/3085
151
+ hash.delete(:id)
152
+ handle_exception do
153
+ rest_client[get_resource_name(entity_type) + "/#{id}"]
154
+ .put(hash.to_json)
155
+ end
156
+ end
157
+
158
+ def new_entity(hash, klass)
159
+ klass.new(hash)
160
+ end
161
+
162
+ def retrieve_all_entities(entity_types)
163
+ entity_types.each_with_object({}) do |(_, entity_type), result_hash|
164
+ # method call for get each entities
165
+ # build hash of entity name to array of the entities
166
+ method_name = "get_#{entity_type.underscore.pluralize}"
167
+ key_name = entity_type.underscore
168
+ result_hash[key_name] = send(method_name)
169
+ end
170
+ end
171
+
172
+ def get_resource_name(entity_type)
173
+ if @api_version == 'v1beta1'
174
+ entity_type.pluralize.camelize(:lower)
175
+ else
176
+ entity_type.pluralize.downcase
177
+ end
178
+ end
179
+
180
+ def ssl_options(client_cert: nil, client_key: nil, ca_file: nil,
181
+ verify_ssl: OpenSSL::SSL::VERIFY_PEER)
182
+ @ssl_options = {
183
+ ca_file: ca_file,
184
+ verify_ssl: verify_ssl,
185
+ client_cert: client_cert,
186
+ client_key: client_key
187
+ }
188
+ end
189
+ end
190
+ end
191
+ end
@@ -1,15 +1,16 @@
1
1
  require 'delegate'
2
-
3
2
  module Kubeclient
4
- # Kubernetes Entity List
5
- class EntityList < DelegateClass(Array)
6
- attr_reader :kind, :resourceVersion
3
+ module Common
4
+ # Kubernetes Entity List
5
+ class EntityList < DelegateClass(Array)
6
+ attr_reader :kind, :resourceVersion
7
7
 
8
- def initialize(kind, resource_version, list)
9
- @kind = kind
10
- # rubocop:disable Style/VariableName
11
- @resourceVersion = resource_version
12
- super(list)
8
+ def initialize(kind, resource_version, list)
9
+ @kind = kind
10
+ # rubocop:disable Style/VariableName
11
+ @resourceVersion = resource_version
12
+ super(list)
13
+ end
13
14
  end
14
15
  end
15
16
  end
@@ -1,4 +1,4 @@
1
1
  # Kubernetes REST-API Client
2
2
  module Kubeclient
3
- VERSION = '0.1.8'
3
+ VERSION = '0.1.9'
4
4
  end
@@ -1,4 +1,7 @@
1
1
  require 'recursive_open_struct'
2
-
3
- class WatchNotice < RecursiveOpenStruct
2
+ module Kubeclient
3
+ module Common
4
+ class WatchNotice < RecursiveOpenStruct
5
+ end
6
+ end
4
7
  end
@@ -1,40 +1,41 @@
1
1
  require 'json'
2
2
  require 'net/http'
3
-
4
3
  module Kubeclient
5
- # HTTP Stream used to watch changes on entities
6
- class WatchStream
7
- def initialize(uri, options)
8
- @uri = uri
9
- @http = nil
10
- @options = options.merge(read_timeout: nil)
11
- end
4
+ module Common
5
+ # HTTP Stream used to watch changes on entities
6
+ class WatchStream
7
+ def initialize(uri, options)
8
+ @uri = uri
9
+ @http = nil
10
+ @options = options.merge(read_timeout: nil)
11
+ end
12
12
 
13
- def each
14
- @finished = false
15
- @http = Net::HTTP.start(@uri.host, @uri.port, @options)
13
+ def each
14
+ @finished = false
15
+ @http = Net::HTTP.start(@uri.host, @uri.port, @options)
16
16
 
17
- buffer = ''
18
- request = Net::HTTP::Get.new(@uri)
17
+ buffer = ''
18
+ request = Net::HTTP::Get.new(@uri)
19
19
 
20
- @http.request(request) do |response|
21
- unless response.is_a? Net::HTTPSuccess
22
- fail KubeException.new(response.code, response.message)
23
- end
24
- response.read_body do |chunk|
25
- buffer << chunk
26
- while (line = buffer.slice!(/.+\n/))
27
- yield WatchNotice.new(JSON.parse(line))
20
+ @http.request(request) do |response|
21
+ unless response.is_a? Net::HTTPSuccess
22
+ fail KubeException.new(response.code, response.message)
23
+ end
24
+ response.read_body do |chunk|
25
+ buffer << chunk
26
+ while (line = buffer.slice!(/.+\n/))
27
+ yield WatchNotice.new(JSON.parse(line))
28
+ end
28
29
  end
29
30
  end
31
+ rescue Errno::EBADF
32
+ raise unless @finished
30
33
  end
31
- rescue Errno::EBADF
32
- raise unless @finished
33
- end
34
34
 
35
- def finish
36
- @finished = true
37
- @http.finish if !@http.nil? && @http.started?
35
+ def finish
36
+ @finished = true
37
+ @http.finish if !@http.nil? && @http.started?
38
+ end
38
39
  end
39
40
  end
40
41
  end
@@ -66,7 +66,7 @@ class KubeClientTest < MiniTest::Test
66
66
  end
67
67
 
68
68
  def test_api
69
- stub_request(:get, 'http://localhost:8080/api/')
69
+ stub_request(:get, 'http://localhost:8080/api')
70
70
  .to_return(status: 200, body: open_test_json_file('versions_list.json'))
71
71
 
72
72
  client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
@@ -75,34 +75,34 @@ class KubeClientTest < MiniTest::Test
75
75
  end
76
76
 
77
77
  def test_api_valid
78
- stub_request(:get, 'http://localhost:8080/api/')
78
+ stub_request(:get, 'http://localhost:8080/api')
79
79
  .to_return(status: 200, body: open_test_json_file('versions_list.json'))
80
80
 
81
- client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
81
+ client = Kubeclient::Client.new 'http://localhost:8080/api/'
82
82
  assert client.api_valid?
83
83
  end
84
84
 
85
85
  def test_api_valid_with_invalid_json
86
- stub_request(:get, 'http://localhost:8080/api/')
86
+ stub_request(:get, 'http://localhost:8080/api')
87
87
  .to_return(status: 200, body: '{}')
88
88
 
89
- client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
89
+ client = Kubeclient::Client.new 'http://localhost:8080/api/'
90
90
  refute client.api_valid?
91
91
  end
92
92
 
93
93
  def test_api_valid_with_bad_endpoint
94
- stub_request(:get, 'http://localhost:8080/api/')
94
+ stub_request(:get, 'http://localhost:8080/api')
95
95
  .to_return(status: [404, 'Resource Not Found'])
96
96
 
97
- client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
97
+ client = Kubeclient::Client.new 'http://localhost:8080/api/'
98
98
  assert_raises(KubeException) { client.api_valid? }
99
99
  end
100
100
 
101
101
  def test_api_valid_with_non_json
102
- stub_request(:get, 'http://localhost:8080/api/')
102
+ stub_request(:get, 'http://localhost:8080/api')
103
103
  .to_return(status: 200, body: '<html></html>')
104
104
 
105
- client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
105
+ client = Kubeclient::Client.new 'http://localhost:8080/api/'
106
106
  assert_raises(JSON::ParserError) { client.api_valid? }
107
107
  end
108
108
 
@@ -131,7 +131,7 @@ class KubeClientTest < MiniTest::Test
131
131
  services = client.get_services
132
132
 
133
133
  refute_empty(services)
134
- assert_instance_of(Kubeclient::EntityList, services)
134
+ assert_instance_of(Kubeclient::Common::EntityList, services)
135
135
  assert_equal('Service', services.kind)
136
136
  assert_equal(2, services.size)
137
137
  assert_instance_of(Kubeclient::Service, services[0])
@@ -145,7 +145,7 @@ class KubeClientTest < MiniTest::Test
145
145
 
146
146
  client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
147
147
  pods = client.get_pods
148
- assert_instance_of(Kubeclient::EntityList, pods)
148
+ assert_instance_of(Kubeclient::Common::EntityList, pods)
149
149
  assert_equal(0, pods.size)
150
150
  end
151
151
 
@@ -180,12 +180,13 @@ class KubeClientTest < MiniTest::Test
180
180
  client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
181
181
  result = client.all_entities
182
182
  assert_equal(7, result.keys.size)
183
- assert_instance_of(Kubeclient::EntityList, result['node'])
184
- assert_instance_of(Kubeclient::EntityList, result['service'])
185
- assert_instance_of(Kubeclient::EntityList, result['replication_controller'])
186
- assert_instance_of(Kubeclient::EntityList, result['pod'])
187
- assert_instance_of(Kubeclient::EntityList, result['event'])
188
- assert_instance_of(Kubeclient::EntityList, result['namespace'])
183
+ assert_instance_of(Kubeclient::Common::EntityList, result['node'])
184
+ assert_instance_of(Kubeclient::Common::EntityList, result['service'])
185
+ assert_instance_of(Kubeclient::Common::EntityList,
186
+ result['replication_controller'])
187
+ assert_instance_of(Kubeclient::Common::EntityList, result['pod'])
188
+ assert_instance_of(Kubeclient::Common::EntityList, result['event'])
189
+ assert_instance_of(Kubeclient::Common::EntityList, result['namespace'])
189
190
  assert_instance_of(Kubeclient::Service, result['service'][0])
190
191
  assert_instance_of(Kubeclient::Node, result['node'][0])
191
192
  assert_instance_of(Kubeclient::Event, result['event'][0])
data/test/test_watch.rb CHANGED
@@ -16,7 +16,7 @@ class TestWatch < MiniTest::Test
16
16
  client = Kubeclient::Client.new 'http://localhost:8080/api/', 'v1beta3'
17
17
 
18
18
  client.watch_pods.to_enum.with_index do |notice, index|
19
- assert_instance_of(WatchNotice, notice)
19
+ assert_instance_of(Kubeclient::Common::WatchNotice, notice)
20
20
  assert_equal(expected[index]['type'], notice.type)
21
21
  assert_equal('Pod', notice.object.kind)
22
22
  assert_equal('php', notice.object.metadata.name)
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.8
4
+ version: 0.1.9
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-26 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -152,6 +152,7 @@ files:
152
152
  - Rakefile
153
153
  - kubeclient.gemspec
154
154
  - lib/kubeclient.rb
155
+ - lib/kubeclient/common.rb
155
156
  - lib/kubeclient/entity_list.rb
156
157
  - lib/kubeclient/kube_exception.rb
157
158
  - lib/kubeclient/version.rb