diplomat 0.18.0 → 0.19.0
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 +17 -0
- data/lib/diplomat.rb +2 -0
- data/lib/diplomat/acl.rb +5 -11
- data/lib/diplomat/event.rb +6 -3
- data/lib/diplomat/health.rb +2 -0
- data/lib/diplomat/kv.rb +1 -1
- data/lib/diplomat/node.rb +5 -3
- data/lib/diplomat/rest_client.rb +2 -1
- data/lib/diplomat/service.rb +2 -2
- data/lib/diplomat/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: 445cf50cabc901de363e7692e3ab395c24fc0f16
|
|
4
|
+
data.tar.gz: e2977150c4927b89d3c4dedf415ed69d0a022fa4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af47156e803a93218c018178b758e8dba6730156914f8c8eaabaf5d87d4b5f32db99352b5c1c95b5426c7a5f098b7991d7d79fe93ba282397d458892f2100c73
|
|
7
|
+
data.tar.gz: 953d8fd1908d93753588d907f0984ad98d6bb8365aebcc4c13fbe019c081398e207d89a11d8f7f2bf616868b758c71e48c83a3b84b4252906d2dee002e0089f0
|
data/README.md
CHANGED
|
@@ -39,6 +39,10 @@ production:
|
|
|
39
39
|
|
|
40
40
|
[See here](http://www.consul.io/intro/). I managed to roll it out on my production machines with the help of [Ansible](http://www.ansible.com/) in one working day.
|
|
41
41
|
|
|
42
|
+
### Which versions of Ruby does Diplomat support?
|
|
43
|
+
|
|
44
|
+
Check out [Travis](https://travis-ci.org/WeAreFarmGeek/diplomat) to see which versions of ruby we currently test when we're making builds.
|
|
45
|
+
|
|
42
46
|
## Usage
|
|
43
47
|
|
|
44
48
|
[The most up to date place to read about the API is here.](http://rubydoc.info/github/WeAreFarmGeek/diplomat)
|
|
@@ -82,6 +86,12 @@ Diplomat::Kv.get('foo/', recurse: true)
|
|
|
82
86
|
# => [{:key=>"foo/a", :value=>"lorem"}, {:key=>"foo/b", :value=>"ipsum"}, {:key=>"foo/c", :value=>"dolor"}]
|
|
83
87
|
```
|
|
84
88
|
|
|
89
|
+
Or list all available keys:
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
Diplomat::Kv.get('/', :keys => true) # => ['foo/a', 'foo/b']
|
|
93
|
+
```
|
|
94
|
+
|
|
85
95
|
### Nodes
|
|
86
96
|
|
|
87
97
|
#### Getting
|
|
@@ -100,6 +110,13 @@ nodes = Diplomat::Node.get_all
|
|
|
100
110
|
# => [#<OpenStruct Address="10.1.10.12", Node="foo">, #<OpenStruct Address="10.1.10.13", Node="bar">]
|
|
101
111
|
```
|
|
102
112
|
|
|
113
|
+
Get all nodes for a particular datacenter
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
nodes = Diplomat::Node.get_all({ :dc => 'My_Datacenter' })
|
|
117
|
+
# => [#<OpenStruct Address="10.1.10.12", Node="foo">, #<OpenStruct Address="10.1.10.13", Node="bar">]
|
|
118
|
+
```
|
|
119
|
+
|
|
103
120
|
Register a node:
|
|
104
121
|
|
|
105
122
|
```ruby
|
data/lib/diplomat.rb
CHANGED
data/lib/diplomat/acl.rb
CHANGED
|
@@ -46,14 +46,8 @@ module Diplomat
|
|
|
46
46
|
def list
|
|
47
47
|
url = ["/v1/acl/list"]
|
|
48
48
|
url += check_acl_token
|
|
49
|
-
raw = @conn_no_err.get concat_url url
|
|
50
|
-
|
|
51
|
-
if raw.status == 200
|
|
52
|
-
@raw = raw
|
|
53
|
-
return parse_body
|
|
54
|
-
else
|
|
55
|
-
raise Diplomat::UnknownStatus, "status #{raw.status}"
|
|
56
|
-
end
|
|
49
|
+
@raw = @conn_no_err.get concat_url url
|
|
50
|
+
return parse_body
|
|
57
51
|
end
|
|
58
52
|
|
|
59
53
|
# Update an Acl definition, create if not present
|
|
@@ -69,7 +63,7 @@ module Diplomat
|
|
|
69
63
|
req.url concat_url url
|
|
70
64
|
req.body = value.to_json
|
|
71
65
|
end
|
|
72
|
-
|
|
66
|
+
return parse_body
|
|
73
67
|
end
|
|
74
68
|
|
|
75
69
|
# Create an Acl definition
|
|
@@ -83,7 +77,7 @@ module Diplomat
|
|
|
83
77
|
req.url concat_url url
|
|
84
78
|
req.body = value.to_json
|
|
85
79
|
end
|
|
86
|
-
|
|
80
|
+
return parse_body
|
|
87
81
|
end
|
|
88
82
|
|
|
89
83
|
# Destroy an ACl token by its id
|
|
@@ -94,7 +88,7 @@ module Diplomat
|
|
|
94
88
|
url = ["/v1/acl/destroy/#{@id}"]
|
|
95
89
|
url += check_acl_token
|
|
96
90
|
@raw = @conn.put concat_url url
|
|
97
|
-
@raw.body == "true"
|
|
91
|
+
return @raw.body == "true"
|
|
98
92
|
end
|
|
99
93
|
end
|
|
100
94
|
end
|
data/lib/diplomat/event.rb
CHANGED
|
@@ -76,13 +76,16 @@ module Diplomat
|
|
|
76
76
|
when :reject
|
|
77
77
|
raise Diplomat::EventAlreadyExists, name
|
|
78
78
|
when :return
|
|
79
|
-
|
|
79
|
+
# Always set the response to 200 so we always return
|
|
80
|
+
# the response body.
|
|
81
|
+
@raw.status = 200
|
|
82
|
+
@raw = parse_body
|
|
80
83
|
return return_payload
|
|
81
84
|
end
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
@raw = wait_for_next_event(url)
|
|
85
|
-
parse_body
|
|
88
|
+
@raw = parse_body
|
|
86
89
|
return_payload
|
|
87
90
|
end
|
|
88
91
|
|
|
@@ -130,7 +133,7 @@ module Diplomat
|
|
|
130
133
|
event_token = :last
|
|
131
134
|
when :wait
|
|
132
135
|
@raw = wait_for_next_event(url)
|
|
133
|
-
parse_body
|
|
136
|
+
@raw = parse_body
|
|
134
137
|
# If it's possible for two events to arrive at once,
|
|
135
138
|
# this needs to #find again:
|
|
136
139
|
event = @raw.last
|
data/lib/diplomat/health.rb
CHANGED
|
@@ -45,10 +45,12 @@ module Diplomat
|
|
|
45
45
|
# Get service health
|
|
46
46
|
# @param s [String] the service
|
|
47
47
|
# @param options [Hash] :dc string for dc specific query
|
|
48
|
+
# @param options [Hash] :state string for specific service state
|
|
48
49
|
# @return [OpenStruct] all data associated with the node
|
|
49
50
|
def service s, options=nil
|
|
50
51
|
url = ["/v1/health/service/#{s}"]
|
|
51
52
|
url << use_named_parameter('dc', options[:dc]) if options and options[:dc]
|
|
53
|
+
url << options[:state] if options and options[:state]
|
|
52
54
|
|
|
53
55
|
# If the request fails, it's probably due to a bad path
|
|
54
56
|
# so return a PathNotFound error.
|
data/lib/diplomat/kv.rb
CHANGED
data/lib/diplomat/node.rb
CHANGED
|
@@ -29,11 +29,13 @@ module Diplomat
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Get all the nodes
|
|
32
|
+
# @param options [Hash] :dc string for dc specific query
|
|
32
33
|
# @return [OpenStruct] the list of all nodes
|
|
33
|
-
def get_all
|
|
34
|
-
url = "/v1/catalog/nodes"
|
|
34
|
+
def get_all options=nil
|
|
35
|
+
url = ["/v1/catalog/nodes"]
|
|
36
|
+
url << use_named_parameter('dc', options[:dc]) if options and options[:dc]
|
|
35
37
|
begin
|
|
36
|
-
ret = @conn.get url
|
|
38
|
+
ret = @conn.get concat_url url
|
|
37
39
|
rescue Faraday::ClientError
|
|
38
40
|
raise Diplomat::PathNotFound
|
|
39
41
|
end
|
data/lib/diplomat/rest_client.rb
CHANGED
|
@@ -71,7 +71,8 @@ module Diplomat
|
|
|
71
71
|
|
|
72
72
|
# Parse the body, apply it to the raw attribute
|
|
73
73
|
def parse_body
|
|
74
|
-
|
|
74
|
+
return JSON.parse(@raw.body) if @raw.status == 200
|
|
75
|
+
raise Diplomat::UnknownStatus, "status #{@raw.status}"
|
|
75
76
|
end
|
|
76
77
|
|
|
77
78
|
# Return @raw with Value fields decoded
|
data/lib/diplomat/service.rb
CHANGED
|
@@ -27,8 +27,8 @@ module Diplomat
|
|
|
27
27
|
# so return a PathNotFound error.
|
|
28
28
|
begin
|
|
29
29
|
ret = @conn.get concat_url url
|
|
30
|
-
rescue Faraday::ClientError
|
|
31
|
-
raise Diplomat::PathNotFound
|
|
30
|
+
rescue Faraday::ClientError => e
|
|
31
|
+
raise Diplomat::PathNotFound, e
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
if meta and ret.headers
|
data/lib/diplomat/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: diplomat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.19.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Hamelink
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|