consul-templaterb 1.4.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60bb02ded0414b955e2ddf979bd02587fd352af8dbb07c162e1985a0173b5fa3
4
- data.tar.gz: dd78711af97ad24c9b01a228cfaabc0376484ef24fdc6c86fd7e541cf8421a05
3
+ metadata.gz: fc502021c589486d5467570135c409154b48de0829358bc0f5a261c93cb4bf83
4
+ data.tar.gz: 77d2214c3b8d4db64d28911f76d7f4148f0e54aa00a504f116f0b06ed7d227fd
5
5
  SHA512:
6
- metadata.gz: 32632e75b3742427a40373b36caeba46aab17eb634513a1c0d137be65adfb1ce02365c65024df651494bf635464268a2f2555dddd01baade3cad4ef03ccb1d4e
7
- data.tar.gz: 129215ca52ccb173b31c0939c5438ad5bebb888b15733172ba333fca2f7a03016291a3ec542570679e38e9b64f5f3bb6a983129a461178fb3f8705cc57a3966b
6
+ metadata.gz: 730e29b4453d6e6b298bc2b1b3b5d57b39ccf6d88231b84ac60fe04998ca131a5294d450219f7432f7de80813de8ee32c279ed11d88547fe11a7926122136920
7
+ data.tar.gz: 9b8fe26cee53f5417418ce9574e076fc3ffc40a2a61f9f211cd516bfcb591d5fd146ec7b664fd86d8170fc6d25e6eef3c8c964e7e2fbe52ca1bc8468bd7a081b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## (UNRELEASED)
4
4
 
5
+ ## 1.5.0 (August 17, 2018)
6
+
7
+ IMPROVEMENTS:
8
+
9
+ * fixed small errors in documentation
10
+ * added `-T` flag to control ERB trim mode with default value of `-`
11
+
5
12
  ## 1.4.0 (July 23, 2018)
6
13
 
7
14
  IMPROVEMENTS:
data/README.md CHANGED
@@ -28,6 +28,9 @@ consul-template.
28
28
  It provides a very [simple API](TemplateAPI.md) to write your own templates
29
29
  with fully [working examples](samples/).
30
30
 
31
+ It also allow to display a very nice and hi-performance HTML5 UI for Consul,
32
+ see [consul-ui](samples/consul-ui) for details.
33
+
31
34
  ## Differences with HashiCorp's consul-template
32
35
 
33
36
  [Hashicorp's Consul Template](https://github.com/hashicorp/consul-template)
@@ -141,6 +144,7 @@ USAGE: consul-templaterb [[options]]
141
144
  -r, --retry-delay=<min_duration> Min Retry delay on Error/Missing Consul Index
142
145
  -k, --hot-reload=<behavior> Control hot reload behaviour, one of :[die (kill daemon on hot reload failure), keep (on error, keep running), disable (hot reload disabled)]
143
146
  -K, --sig-term=kill_signal Signal to send to next --exec command on kill, default=TERM
147
+ -T, --trim-mode=trim_mode ERB Trim mode to use (- by default)
144
148
  -R, --sig-reload=reload_signal Signal to send to next --exec command on reload (NONE supported), default=HUP
145
149
  -e, --exec=<command> Execute the following command
146
150
  -d, --debug-network-usage Debug the network usage
data/TemplateAPI.md CHANGED
@@ -279,6 +279,8 @@ consul-templaterb --template "source.html.erb:dest.html:reload_command:params.ya
279
279
  [...]
280
280
  ```
281
281
 
282
+ See [samples/common/header.html.erb](samples/common/header.html.erb) for example of usage.
283
+
282
284
  ## secrets(prefix)
283
285
 
284
286
  It requires that a Vault token is given either in parameter or in environment variable
@@ -335,5 +337,3 @@ secret('secret/foo', [force_ttl: intInSecond])
335
337
 
336
338
  </div>
337
339
  </details>
338
-
339
- See [samples/common/header.html.erb](samples/common/header.html.erb) for example of usage.
@@ -17,6 +17,9 @@ def compute_default_output(source)
17
17
  end
18
18
 
19
19
  options = {
20
+ erb: {
21
+ trim_mode: '-', # trim_mode for ERB
22
+ },
20
23
  vault: {
21
24
  debug: {
22
25
  network: false
@@ -138,6 +141,11 @@ optparse = OptionParser.new do |opts|
138
141
  cur_sig_term = compute_signal(sig, nil)
139
142
  end
140
143
 
144
+ opts.on('-T', '--trim-mode=trim_mode', String,
145
+ "ERB Trim mode to use (#{options[:erb][:trim_mode]} by default)") do |trim_mode|
146
+ options[:erb][:trim_mode] = trim_mode
147
+ end
148
+
141
149
  opts.on('-R', '--sig-reload=reload_signal', String,
142
150
  "Signal to send to next --exec command on reload (NONE supported), default=#{cur_sig_reload}") do |sig|
143
151
  cur_sig_reload = compute_signal(sig, 'NONE')
@@ -265,7 +273,7 @@ EM.epoll
265
273
 
266
274
  consul_conf = Consul::Async::ConsulConfiguration.new(options[:consul])
267
275
  vault_conf = Consul::Async::VaultConfiguration.new(options[:vault])
268
- template_manager = Consul::Async::EndPointsManager.new(consul_conf, vault_conf)
276
+ template_manager = Consul::Async::EndPointsManager.new(consul_conf, vault_conf, options[:erb][:trim_mode])
269
277
 
270
278
  ARGV.each do |tpl|
271
279
  dest = compute_default_output(tpl)
@@ -21,9 +21,10 @@ module Consul
21
21
 
22
22
  class EndPointsManager
23
23
  attr_reader :consul_conf, :vault_conf, :net_info, :start_time
24
- def initialize(consul_configuration, vault_configuration)
24
+ def initialize(consul_configuration, vault_configuration, trim_mode = nil)
25
25
  @consul_conf = consul_configuration
26
26
  @vault_conf = vault_configuration
27
+ @trim_mode = trim_mode
27
28
  @endpoints = {}
28
29
  @iteration = 1
29
30
  @start_time = Time.now.utc
@@ -169,7 +170,7 @@ module Consul
169
170
  current_erb_path: tpl_file_path,
170
171
  params: params
171
172
  }
172
- result = ERB.new(tpl).result(binding)
173
+ result = ERB.new(tpl, nil, @trim_mode).result(binding)
173
174
  @context = old_value
174
175
  result
175
176
  rescue StandardError => e
@@ -1,5 +1,5 @@
1
1
  module Consul
2
2
  module Async
3
- VERSION = '1.4.0'.freeze
3
+ VERSION = '1.5.0'.freeze
4
4
  end
5
5
  end
@@ -4,6 +4,23 @@ A simple HTML5 app that displays all services within Consul with AJAX requests.
4
4
  It supports fitering based on tags and does not rely on Consul to display pages,
5
5
  meaning that it can be scaled horizontally without any troubles with Consul.
6
6
 
7
+ ## Is it prod ready?
8
+
9
+ This application is used for several months within Criteo to replace Consul native interface and
10
+ is used daily by hundreds of users. At Criteo, consul-templaterb creates the static web, updates
11
+ it continuously and all the static pages are served using nginx, but any web server might be used.
12
+
13
+ Criteo has more than 20k Consul nodes on 8 datacenters, so it should work for most installations.
14
+
15
+ It has far more performance than most Consul UIs, the only downside is that the whole application
16
+ is Read-Only (but it would be possible to add RW support with CORS to modify values within
17
+ Consul).
18
+
19
+ You can watch a [video comparison](https://www.youtube.com/watch?v=o7VEox2FSEs) of this application
20
+ with the new native Consul UI interface of Consul 1.2.x, performance gap is especially strong
21
+ when using remote Datacenters (in the video around 01:10) where this app displays all information
22
+ from datacenter in Tokyo from Paris.
23
+
7
24
  ## Usage
8
25
 
9
26
  ```shell
@@ -35,9 +52,9 @@ Will generate index.html and consul_template.json in your directory, so you migh
35
52
 
36
53
  ### Filtering services
37
54
 
38
- This app supports the following environement variables:
55
+ This app supports the following environment variables:
39
56
 
40
57
  * SERVICES_TAG_FILTER: basic tag filter for service (default HTTP)
41
58
  * INSTANCE_MUST_TAG: Second level of filtering (optional, default to SERVICES_TAG_FILTER)
42
59
  * INSTANCE_EXCLUDE_TAG: Exclude instances having the given tag (default: canary)
43
- * EXCLUDE_SERVICES: comma-separated services to exclude (default: consul-agent-http,mesos-slave,mesos-agent-watcher)
60
+ * EXCLUDE_SERVICES: comma-separated services to exclude (default: consul-agent-http,mesos-slave,mesos-agent-watcher)
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.0
4
+ version: 1.5.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: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2018-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request