kubr 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/kubr/client.rb +26 -12
- data/lib/kubr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0a93143ea1389eb7db5da7f3dea0cc05bf3ab3a
|
4
|
+
data.tar.gz: 65b6857bf3c16b657406a46c08c96f36db6cdf49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e2ff6b101743c7cc3bfd4fbe3a6d4362eb8cfa91507ddd247b44e5c45ea7451e1e24dd56b06420f66d1803858c89e19b092ad339a155d962f87c3d787044de0
|
7
|
+
data.tar.gz: dca7dc2a4b3968dda78502fde2ba88c624ab9b681040305e290eec41d76074e20b2ca971e1be2a8f696e723a90a4c5e5464adf087874926ade05ebd359e21306
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
kubr
|
2
2
|
=====
|
3
3
|
|
4
4
|
Ruby client for [Kubrnetes](https://github.com/GoogleCloudPlatform/Kubrnetes)
|
@@ -8,14 +8,14 @@ Installation
|
|
8
8
|
------------
|
9
9
|
|
10
10
|
```
|
11
|
-
gem install
|
11
|
+
gem install kubr
|
12
12
|
```
|
13
13
|
|
14
14
|
Usage
|
15
15
|
-----
|
16
16
|
|
17
|
-
```
|
18
|
-
require '
|
17
|
+
```ruby
|
18
|
+
require 'kubr'
|
19
19
|
|
20
20
|
Kubr.configure do |config|
|
21
21
|
config.url = 'https://130.211.56.93/api/v1beta1'
|
data/lib/kubr/client.rb
CHANGED
@@ -12,32 +12,46 @@ module Kubr
|
|
12
12
|
:verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
13
13
|
end
|
14
14
|
|
15
|
-
def send_request(method, path, body=nil)
|
15
|
+
def send_request(method, path, labels=nil, body=nil)
|
16
16
|
args = [method]
|
17
17
|
args << body.to_json if body
|
18
|
+
path += parse_labels_hash(labels) if labels
|
18
19
|
process_response @cl[path].send(*args)
|
20
|
+
rescue RestClient::UnprocessableEntity, RestClient::InternalServerError => e
|
21
|
+
process_response e.response
|
19
22
|
end
|
20
23
|
|
21
24
|
def process_response(response)
|
22
25
|
JSON.parse(response).recursively_symbolize_keys!
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def parse_labels_hash(labels)
|
29
|
+
labels_string = '?labels='
|
30
|
+
labels.each { |key, value| labels_string << "#{key}=#{value}," }
|
31
|
+
labels_string
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
['minion', 'pod', 'service', 'replicationController'].each do |entity|
|
35
|
+
define_method "list_#{entity.underscore.pluralize}" do |labels=nil|
|
36
|
+
send_request :get, entity.pluralize, labels
|
33
37
|
end
|
34
38
|
|
35
|
-
define_method "
|
36
|
-
send_request :
|
39
|
+
define_method "get_#{entity.underscore}" do |id|
|
40
|
+
send_request :get, "#{entity.pluralize}/#{id}"
|
37
41
|
end
|
38
42
|
|
39
|
-
|
40
|
-
|
43
|
+
unless entity == 'minion'
|
44
|
+
define_method "create_#{entity.underscore}" do |config|
|
45
|
+
send_request :post, entity.pluralize, config
|
46
|
+
end
|
47
|
+
|
48
|
+
define_method "update_#{entity.underscore}" do |config|
|
49
|
+
send_request :put, entity.pluralize, config
|
50
|
+
end
|
51
|
+
|
52
|
+
define_method "delete_#{entity.underscore}" do |id|
|
53
|
+
send_request :delete, "#{entity.pluralize}/#{id}"
|
54
|
+
end
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
data/lib/kubr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andriy Yurchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|