consul-templaterb 1.15.3 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/TemplateAPI.md +15 -0
- data/lib/consul/async/consul_template.rb +16 -0
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/consul_nodes.json.erb +1 -1
- data/samples/consul-ui/consul_services.json.erb +2 -2
- data/samples/metrics.erb +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a89758ade44e162e917282e2f01c0ff0631261dc04705ccf5a284e66c0a8ec4c
|
4
|
+
data.tar.gz: 158939ccb266b44496bb6240a5bf4da5c558ea6310abcc5e3fd2922eac9a102c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72d8b16ea9f95a9bf742a417c2e6cf0bc984eeb66dd577407af5e699e37bb1ac9015bcd169ecb1a2ed5ed56d3a2aa0c8cde5224ed5f1cae822ea378a3c4a1faa
|
7
|
+
data.tar.gz: 1306143770c8d18000db48572f66842bbdb74846ce92c08c3361d786c7ca16df215f961eba90493f55b67c5d05add9ff7fbc8448641e41d80573eb167d53220b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## (UNRELEASED)
|
4
4
|
|
5
|
+
## 1.16.0 (July 8, 2019)
|
6
|
+
|
7
|
+
Added new helpers for `service()`
|
8
|
+
|
9
|
+
* `node_meta` return `['Node']['Meta'] or empty hash
|
10
|
+
* `service_meta` return `['Service']['Meta'] or empty hash for old consul versions
|
11
|
+
* `service_or_node_meta_value(key)` return a the value associated with key in meta from
|
12
|
+
service if in service, from node if in node, or nil if meta found nowhere.
|
13
|
+
|
5
14
|
## 1.15.3 (June 20, 2019)
|
6
15
|
|
7
16
|
Improved consul-ui Javascript #37 thanks to [@warrenseine](https://github.com/warrenseine)
|
data/TemplateAPI.md
CHANGED
@@ -116,11 +116,26 @@ services that are passing or not. An optional argument passing might be used to
|
|
116
116
|
|
117
117
|
### Helpers
|
118
118
|
|
119
|
+
#### node_meta
|
120
|
+
|
121
|
+
This function returns a Hash of object `['Node']['Meta']` (will return empty hash if very old version of Consul not
|
122
|
+
supporting it)
|
123
|
+
|
119
124
|
#### service_address
|
120
125
|
|
121
126
|
This object also contains a Helper to get easily the correct Address by using `service_address` which returns
|
122
127
|
the optional `['Service']['Address']` if found or `['Node']['Address']` otherwise.
|
123
128
|
|
129
|
+
#### service_meta
|
130
|
+
|
131
|
+
This helper function will return a Hash or `['Service']['Meta']` and will return empty hash if not supported
|
132
|
+
by old versions of Consul (< 1.1.0)
|
133
|
+
|
134
|
+
#### service_or_node_meta_value(key)
|
135
|
+
|
136
|
+
This function will return a string of `['Service']['Meta']` if key is found in service meta, or
|
137
|
+
`['Node']['Meta']` or nil if key does not exists in both Service.Meta and Node.Meta.
|
138
|
+
|
124
139
|
#### status
|
125
140
|
|
126
141
|
Computing the status of an instance is non-trivial as it requires to parses all statuses of all checks and take
|
@@ -340,6 +340,11 @@ module Consul
|
|
340
340
|
merge!(obj)
|
341
341
|
end
|
342
342
|
|
343
|
+
# Return ['Node']['Meta']
|
344
|
+
def node_meta
|
345
|
+
self['Node']['Meta'] || {}
|
346
|
+
end
|
347
|
+
|
343
348
|
# Return ['Service']['Address'] if defined, the address of node otherwise
|
344
349
|
def service_address
|
345
350
|
val = self['Service']['Address']
|
@@ -347,6 +352,17 @@ module Consul
|
|
347
352
|
val
|
348
353
|
end
|
349
354
|
|
355
|
+
# Return a defined hash of string valued Service.Meta
|
356
|
+
def service_meta
|
357
|
+
self['Service']['Meta'] || {}
|
358
|
+
end
|
359
|
+
|
360
|
+
# If given key exists in Service.Meta returns it, otherwise the same key from
|
361
|
+
# return Node.Meta, otherwise return nil
|
362
|
+
def service_or_node_meta_value(key)
|
363
|
+
service_meta[key] || node_meta[key]
|
364
|
+
end
|
365
|
+
|
350
366
|
# Return the global state of a Service, will return passing|warning|critical
|
351
367
|
def status
|
352
368
|
ret = 'passing'
|
data/lib/consul/async/version.rb
CHANGED
@@ -52,8 +52,8 @@
|
|
52
52
|
check['notes'] = ncheck['Notes']
|
53
53
|
checks.push(check)
|
54
54
|
end
|
55
|
-
meta = snode
|
56
|
-
node_meta = snode
|
55
|
+
meta = snode.service_meta
|
56
|
+
node_meta = snode.node_meta
|
57
57
|
node_name = snode['Node']['Node']
|
58
58
|
all_nodes[node_name] = { meta: node_meta } if node_name
|
59
59
|
server = { frontend_id: "backend_http__#{service_name}",
|
data/samples/metrics.erb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# EXCLUDE_SERVICES: comma-separated services regexps to exclude (example: lbl7.*,netsvc-probe.*,consul-probed.*)
|
8
8
|
# PROMETHEUS_EXPORTED_SERVICE_META: comma-separated list of meta to export into metrics of service
|
9
9
|
<%
|
10
|
-
service_metas_to_export = (ENV['PROMETHEUS_EXPORTED_SERVICE_META'] || 'version,os,criteo_flavor').split(',')
|
10
|
+
service_metas_to_export = (ENV['PROMETHEUS_EXPORTED_SERVICE_META'] || 'version,os,criteo_flavor,node_group').split(',')
|
11
11
|
|
12
12
|
service_tag_filter = ENV['SERVICES_TAG_FILTER'] || nil
|
13
13
|
instance_must_tag = ENV['INSTANCE_MUST_TAG'] || service_tag_filter
|
@@ -30,9 +30,7 @@
|
|
30
30
|
key = "#{snode['Service']['Service']}"
|
31
31
|
metas = {}
|
32
32
|
service_metas_to_export.each do |k|
|
33
|
-
meta =
|
34
|
-
meta = snode['Service']['Meta'][k] if snode['Service']['Meta']
|
35
|
-
meta = snode['Node']['Meta'][k] if !meta && snode['Node']['Meta']
|
33
|
+
meta = snode.service_or_node_meta_value(k)
|
36
34
|
if meta
|
37
35
|
key += "::#{k}=#{meta}"
|
38
36
|
metas[k] = meta
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consul-templaterb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SRE Core Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|