diplomat 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/diplomat/health.rb +3 -1
- data/lib/diplomat/rest_client.rb +17 -4
- data/lib/diplomat/service.rb +1 -15
- data/lib/diplomat/version.rb +1 -1
- metadata +38 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d49b45dca93184126a7c0762ee8a56e878ef35c578d1e437b8831f01e3956ab
|
4
|
+
data.tar.gz: e3c5bf7d7cfbf00a6b4672a88038427c22adb3f6121f6d11e67f402d65bb8bff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 888579ae16fade603364f7f8aa671c172b2563fcff913d5f5361686406d0ae248e6365ee9c89532dd3127f540d4a41227c6663ad4055cf0d6868f7460b9b75d2
|
7
|
+
data.tar.gz: 484da6f36e8207472912d7b107b8812f008791d83833967902b4e1b21af5cd90ad1ed4c6417c2d83dd466d6792c4b3c01a2d7a3bd035d3c41a28c2f61a0bc370
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Diplomat
|
2
|
-
[![
|
2
|
+
[![Build Status](https://github.com/WeAreFarmGeek/diplomat/workflows/Ruby/badge.svg?branch=master)](https://github.com/WeAreFarmGeek/diplomat/actions?query=branch%3Amaster)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/diplomat.svg)](https://rubygems.org/gems/diplomat) [![Gem](https://img.shields.io/gem/dt/diplomat.svg)](https://rubygems.org/gems/diplomat) [![Code Climate](https://codeclimate.com/github/johnhamelink/diplomat.svg)](https://codeclimate.com/github/WeAreFarmGeek/diplomat) [![Inline docs](http://inch-ci.org/github/wearefarmgeek/diplomat.svg?branch=master)](http://inch-ci.org/github/wearefarmgeek/diplomat)
|
3
4
|
### A HTTP Ruby API for [Consul](http://www.consul.io/)
|
4
5
|
|
5
6
|
![Diplomacy Board Game](http://i.imgur.com/Nkuy4b7.jpg)
|
@@ -41,7 +42,7 @@ production:
|
|
41
42
|
|
42
43
|
### Which versions of Ruby does Diplomat support? Where did my ruby 1.9 compatibility go?
|
43
44
|
|
44
|
-
Check out [
|
45
|
+
Check out [GitHub Actions](https://github.com/WeAreFarmGeek/diplomat/blob/master/.github/workflows/ruby.yml) to see which versions of ruby we currently test when we're making builds.
|
45
46
|
|
46
47
|
We've dropped ruby 1.9 support. You can still depend on Diplomat by directly using the `ruby-1.9-compatible` branch on github, although be advised it's not actively maintained anymore.
|
47
48
|
|
data/lib/diplomat/health.rb
CHANGED
@@ -39,12 +39,14 @@ module Diplomat
|
|
39
39
|
custom_params = []
|
40
40
|
custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
|
41
41
|
custom_params << ['passing'] if options[:passing]
|
42
|
-
custom_params
|
42
|
+
custom_params += [*options[:tag]].map { |value| use_named_parameter('tag', value) } if options[:tag]
|
43
43
|
custom_params << use_named_parameter('near', options[:near]) if options[:near]
|
44
|
+
custom_params << use_named_parameter('node-meta', options[:node_meta]) if options[:node_meta]
|
44
45
|
|
45
46
|
ret = send_get_request(@conn, ["/v1/health/service/#{s}"], options, custom_params)
|
46
47
|
JSON.parse(ret.body).map { |service| OpenStruct.new service }
|
47
48
|
end
|
49
|
+
|
48
50
|
# rubocop:enable Metrics/PerceivedComplexity
|
49
51
|
|
50
52
|
# Get service health
|
data/lib/diplomat/rest_client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'deep_merge'
|
3
|
+
require 'deep_merge/core'
|
4
4
|
|
5
5
|
module Diplomat
|
6
6
|
# Base class for interacting with the Consul RESTful API
|
@@ -140,15 +140,26 @@ module Diplomat
|
|
140
140
|
faraday.request :url_encoded
|
141
141
|
faraday.response :raise_error unless raise_error
|
142
142
|
|
143
|
-
|
143
|
+
# We have to provide a custom params encoder here because Faraday - by default - assumes that
|
144
|
+
# list keys have [] as part of their name. This is however does not match the expectation of
|
145
|
+
# the Consul API, which assumes the same query param to simply be repeated
|
146
|
+
#
|
147
|
+
# So faraday reduces this: http://localhost:8500?a=1&a=2 to http://localhost:8500?a=2 unless you
|
148
|
+
# explicitly tell it not to.
|
149
|
+
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
150
|
+
|
151
|
+
faraday.adapter Faraday.default_adapter
|
144
152
|
end
|
145
153
|
end
|
146
154
|
|
147
155
|
# Converts k/v data into ruby hash
|
148
156
|
def convert_to_hash(data)
|
149
|
-
data.map do |item|
|
157
|
+
data_h = data.map do |item|
|
150
158
|
item[:key].split('/').reverse.reduce(item[:value]) { |h, v| { v => h } }
|
151
|
-
end
|
159
|
+
end
|
160
|
+
data_h.reduce({}) do |dest, source|
|
161
|
+
DeepMerge.deep_merge!(source, dest, { preserve_unmergeables: true })
|
162
|
+
end
|
152
163
|
end
|
153
164
|
|
154
165
|
# Parse the body, apply it to the raw attribute
|
@@ -226,6 +237,8 @@ module Diplomat
|
|
226
237
|
consistency = 'consistent' if options[:consistent]
|
227
238
|
query_params << consistency
|
228
239
|
|
240
|
+
query_params << 'cached' if options[:cached]
|
241
|
+
|
229
242
|
# Parse url host
|
230
243
|
url_prefix = options[:http_addr] if options[:http_addr]
|
231
244
|
{ query_params: query_params, headers: headers, url_prefix: url_prefix }
|
data/lib/diplomat/service.rb
CHANGED
@@ -17,21 +17,7 @@ module Diplomat
|
|
17
17
|
custom_params << use_named_parameter('wait', options[:wait]) if options[:wait]
|
18
18
|
custom_params << use_named_parameter('index', options[:index]) if options[:index]
|
19
19
|
custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]
|
20
|
-
if options[:tag]
|
21
|
-
# tag can be either a String, or an array of strings
|
22
|
-
# by splatting it is guaranteed to be an array of strings
|
23
|
-
[*options[:tag]].each do |value|
|
24
|
-
custom_params << use_named_parameter('tag', value)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# We have to provide a custom params encoder here because Faraday - by default - assumes that
|
29
|
-
# list keys have [] as part of their name. This is however not the case for consul tags, which
|
30
|
-
# just use repeated occurences of the same key.
|
31
|
-
#
|
32
|
-
# So faraday reduces this: http://localhost:8500?a=1&a=2 to http://localhost:8500?a=2 unless you
|
33
|
-
# explicitly tell it not to.
|
34
|
-
options[:params_encoder] = Faraday::FlatParamsEncoder
|
20
|
+
custom_params += [*options[:tag]].map { |value| use_named_parameter('tag', value) } if options[:tag]
|
35
21
|
|
36
22
|
ret = send_get_request(@conn, ["/v1/catalog/service/#{key}"], options, custom_params)
|
37
23
|
if meta && ret.headers
|
data/lib/diplomat/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diplomat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hamelink
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -18,48 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2.
|
22
|
-
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 2.0.1
|
21
|
+
version: '2.2'
|
25
22
|
type: :development
|
26
23
|
prerelease: false
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
requirements:
|
29
26
|
- - "~>"
|
30
27
|
- !ruby/object:Gem::Version
|
31
|
-
version: '2.
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 2.0.1
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: codeclimate-test-reporter
|
37
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: 0.4.0
|
42
|
-
type: :development
|
43
|
-
prerelease: false
|
44
|
-
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 0.4.0
|
28
|
+
version: '2.2'
|
49
29
|
- !ruby/object:Gem::Dependency
|
50
30
|
name: cucumber
|
51
31
|
requirement: !ruby/object:Gem::Requirement
|
52
32
|
requirements:
|
53
33
|
- - "~>"
|
54
34
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
35
|
+
version: '5.3'
|
56
36
|
type: :development
|
57
37
|
prerelease: false
|
58
38
|
version_requirements: !ruby/object:Gem::Requirement
|
59
39
|
requirements:
|
60
40
|
- - "~>"
|
61
41
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
42
|
+
version: '5.3'
|
63
43
|
- !ruby/object:Gem::Dependency
|
64
44
|
name: fakes-rspec
|
65
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,70 +74,84 @@ dependencies:
|
|
94
74
|
requirements:
|
95
75
|
- - "~>"
|
96
76
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
77
|
+
version: '2.2'
|
98
78
|
type: :development
|
99
79
|
prerelease: false
|
100
80
|
version_requirements: !ruby/object:Gem::Requirement
|
101
81
|
requirements:
|
102
82
|
- - "~>"
|
103
83
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
84
|
+
version: '2.2'
|
105
85
|
- !ruby/object:Gem::Dependency
|
106
86
|
name: pry
|
107
87
|
requirement: !ruby/object:Gem::Requirement
|
108
88
|
requirements:
|
109
89
|
- - "~>"
|
110
90
|
- !ruby/object:Gem::Version
|
111
|
-
version: '0.
|
91
|
+
version: '0.14'
|
112
92
|
type: :development
|
113
93
|
prerelease: false
|
114
94
|
version_requirements: !ruby/object:Gem::Requirement
|
115
95
|
requirements:
|
116
96
|
- - "~>"
|
117
97
|
- !ruby/object:Gem::Version
|
118
|
-
version: '0.
|
98
|
+
version: '0.14'
|
119
99
|
- !ruby/object:Gem::Dependency
|
120
100
|
name: rake
|
121
101
|
requirement: !ruby/object:Gem::Requirement
|
122
102
|
requirements:
|
123
103
|
- - "~>"
|
124
104
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
105
|
+
version: 13.0.3
|
126
106
|
type: :development
|
127
107
|
prerelease: false
|
128
108
|
version_requirements: !ruby/object:Gem::Requirement
|
129
109
|
requirements:
|
130
110
|
- - "~>"
|
131
111
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
112
|
+
version: 13.0.3
|
133
113
|
- !ruby/object:Gem::Dependency
|
134
114
|
name: rspec
|
135
115
|
requirement: !ruby/object:Gem::Requirement
|
136
116
|
requirements:
|
137
117
|
- - "~>"
|
138
118
|
- !ruby/object:Gem::Version
|
139
|
-
version: '3.
|
119
|
+
version: '3.10'
|
140
120
|
type: :development
|
141
121
|
prerelease: false
|
142
122
|
version_requirements: !ruby/object:Gem::Requirement
|
143
123
|
requirements:
|
144
124
|
- - "~>"
|
145
125
|
- !ruby/object:Gem::Version
|
146
|
-
version: '3.
|
126
|
+
version: '3.10'
|
147
127
|
- !ruby/object:Gem::Dependency
|
148
128
|
name: rubocop
|
149
129
|
requirement: !ruby/object:Gem::Requirement
|
150
130
|
requirements:
|
151
131
|
- - "~>"
|
152
132
|
- !ruby/object:Gem::Version
|
153
|
-
version: 0.
|
133
|
+
version: 0.93.1
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 0.93.1
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: simplecov
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 0.21.2
|
154
148
|
type: :development
|
155
149
|
prerelease: false
|
156
150
|
version_requirements: !ruby/object:Gem::Requirement
|
157
151
|
requirements:
|
158
152
|
- - "~>"
|
159
153
|
- !ruby/object:Gem::Version
|
160
|
-
version: 0.
|
154
|
+
version: 0.21.2
|
161
155
|
- !ruby/object:Gem::Dependency
|
162
156
|
name: webmock
|
163
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,40 +172,28 @@ dependencies:
|
|
178
172
|
requirements:
|
179
173
|
- - "~>"
|
180
174
|
- !ruby/object:Gem::Version
|
181
|
-
version: '1.
|
182
|
-
- - ">="
|
183
|
-
- !ruby/object:Gem::Version
|
184
|
-
version: 1.0.1
|
175
|
+
version: '1.2'
|
185
176
|
type: :runtime
|
186
177
|
prerelease: false
|
187
178
|
version_requirements: !ruby/object:Gem::Requirement
|
188
179
|
requirements:
|
189
180
|
- - "~>"
|
190
181
|
- !ruby/object:Gem::Version
|
191
|
-
version: '1.
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: 1.0.1
|
182
|
+
version: '1.2'
|
195
183
|
- !ruby/object:Gem::Dependency
|
196
184
|
name: faraday
|
197
185
|
requirement: !ruby/object:Gem::Requirement
|
198
186
|
requirements:
|
199
|
-
- - "
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0.9'
|
202
|
-
- - "<"
|
187
|
+
- - "~>"
|
203
188
|
- !ruby/object:Gem::Version
|
204
|
-
version:
|
189
|
+
version: '1.3'
|
205
190
|
type: :runtime
|
206
191
|
prerelease: false
|
207
192
|
version_requirements: !ruby/object:Gem::Requirement
|
208
193
|
requirements:
|
209
|
-
- - "
|
210
|
-
- !ruby/object:Gem::Version
|
211
|
-
version: '0.9'
|
212
|
-
- - "<"
|
194
|
+
- - "~>"
|
213
195
|
- !ruby/object:Gem::Version
|
214
|
-
version:
|
196
|
+
version: '1.3'
|
215
197
|
description: Diplomat is a simple wrapper for Consul
|
216
198
|
email:
|
217
199
|
- john@johnhamelink.com
|
@@ -263,15 +245,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
245
|
requirements:
|
264
246
|
- - ">="
|
265
247
|
- !ruby/object:Gem::Version
|
266
|
-
version: '2.
|
248
|
+
version: '2.5'
|
267
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
250
|
requirements:
|
269
251
|
- - ">="
|
270
252
|
- !ruby/object:Gem::Version
|
271
253
|
version: '0'
|
272
254
|
requirements: []
|
273
|
-
|
274
|
-
rubygems_version: 2.7.7
|
255
|
+
rubygems_version: 3.1.4
|
275
256
|
signing_key:
|
276
257
|
specification_version: 4
|
277
258
|
summary: Diplomat is a simple wrapper for Consul
|