consul-templaterb 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03d2d0aa9f8c3d39ce100425d7b8a2907eea8e0362383a34e41917af4fc8e2b2
4
- data.tar.gz: e1c0f7dd9bb50d8c10e5be073a00cc52e7de82b0541c8efb973929834b70c48a
3
+ metadata.gz: 4e668f5f7933ba2ec7c0ccad29248d7c2c18cb638931c13dbd4cbb63e55f5908
4
+ data.tar.gz: 61f3edd44ca479edad6c71226f6a2b827ae83f5387726a012f4e2d72d5606f3b
5
5
  SHA512:
6
- metadata.gz: 2bf4ff3ce92344d9e79ba00035072753ec95d860bb143f39b0c858038119adf89014e8b3f7e294b4095158840fe43198252da1626a561f49dce796cd94f8549c
7
- data.tar.gz: d53f88ea95908908aced0200a2afb98d30a156bc4a3f9c0ce66412c1ae6fc4f22f591137bce031fb85e840d7dc7b0116702f891d5a027f44f818e24631b7f116
6
+ metadata.gz: d7fe83b0f9c67abf720fb6a9f941c184c646a9ea5aa7dbeaf244840d9cea52bdbb41a81fb4b79b0a178dc24c3c48e5d75eecd8236731e22ad836262e9ec4d3b3
7
+ data.tar.gz: 878b453b28fb63c430604ae1335a23267f31a5e0dfcc2e1728d5bb919a8cfe907ac1c8458916b6682bb39b7bb51e09baadb5e4bfe97b9b8d6805ce534ab34497
data/.gitignore CHANGED
@@ -13,6 +13,8 @@
13
13
  /samples/*.html
14
14
  /samples/*.txt
15
15
  /samples/*.cfg
16
+ samples/consul-ui/*.html
17
+ samples/consul-ui/*.json
16
18
  /samples/criteo/haproxy.cfg
17
19
  /samples/consul_template
18
20
  /samples/find_blocked_choregraphies
data/CHANGELOG.md CHANGED
@@ -4,7 +4,25 @@
4
4
 
5
5
  IMPROVEMENTS:
6
6
 
7
- # 1.0.10
7
+ ## 1.0.11 (May 11, 2018)
8
+
9
+ BUG FIXES:
10
+
11
+ * Fix for Mac OS X fixed in `1.2-stable` branch of
12
+ [event-machine](https://github.com/eventmachine/eventmachine/), see
13
+ https://github.com/igrigorik/em-http-request/issues/315 for more
14
+ details
15
+ * fixed bug in samples/sample_keys.html.erb
16
+ * Unit tests now catches all `*.erb` files in subdirectories
17
+
18
+ IMPROVEMENTS:
19
+
20
+ * Improved new samples/consul-ui/
21
+ * Documentation typos
22
+ * Help typos fixed
23
+ * Various improvements in [samples/](samples/]
24
+
25
+ # 1.0.10 (May 4, 2018)
8
26
 
9
27
  IMPROVEMENTS:
10
28
 
data/README.md CHANGED
@@ -88,7 +88,7 @@ $ gem install consul-templaterb
88
88
  [...]
89
89
  ```
90
90
 
91
- If you simply want to use the executable on your favorite linux distribution, you
91
+ If you simply want to use the executable on your preferred Linux distribution, you
92
92
  have to install first: ruby and ruby dev.
93
93
 
94
94
  ### Quick install on Ubuntu-Linux
@@ -140,8 +140,8 @@ USAGE: consul-templaterb [[options]]
140
140
  -w, --wait=<min_duration> Wait at least n seconds before each template generation
141
141
  -r, --retry-delay=<min_duration> Min Retry delay on Error/Missing Consul Index
142
142
  -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
- -K, --sig-term=kill_signal Signal to sent to next --exec command on kill, default=TERM
144
- -R, --sig-reload=reload_signal Signal to sent to next --exec command on reload (NONE supported), default=HUP
143
+ -K, --sig-term=kill_signal Signal to send to next --exec command on kill, default=TERM
144
+ -R, --sig-reload=reload_signal Signal to send to next --exec command on reload (NONE supported), default=HUP
145
145
  -e, --exec=<command> Execute the following command
146
146
  -d, --debug-network-usage Debug the network usage
147
147
  -t erb_file:[output]:[command]:[params_file],
@@ -153,8 +153,8 @@ When launched with file arguments ending with .erb, the executable will assume
153
153
  the file is a template and will render the corresponding file without the
154
154
  `.erb` extension.
155
155
 
156
- It means that you can call consul-templaterb with *.erb arguments, the shell
157
- will then substitute all files and render it by removing the .erb extension as
156
+ It means that you can call consul-templaterb with `*.erb` arguments, the shell
157
+ will then substitute all files and render it by removing the `.erb` extension as
158
158
  if the `--template my_file.ext.erb:myfile.ext` was used.
159
159
 
160
160
  ### Generate multiple templates
@@ -222,7 +222,7 @@ examples:
222
222
  7. [Services in JSON](samples/consul_template.json.erb)
223
223
  8. [Generate HaProxy Configuration](samples/ha_proxy.cfg.erb)
224
224
 
225
- If you want to test it quickly, you might try with (assuming you consul agent is listening on
225
+ If you want to test it quickly, you might try with (assuming your consul agent is listening on
226
226
  `http://localhost:8500`):
227
227
 
228
228
  ```shell
@@ -253,11 +253,11 @@ push git commits and tags, and push the `.gem` file to [rubygems.org](https://ru
253
253
 
254
254
  Here are the known bugs of the application:
255
255
 
256
- * [ ] On Mac OS X, with many services, consul-templaterb sometimes crashes when watching lots of changes (more than 2k
256
+ * [x] On Mac OS X, with many services, consul-templaterb sometimes crashes when watching lots of changes (more than 2k
257
257
  watches) at the same time. This bug is
258
258
  [probably a race condition in `em-http-request`](https://github.com/igrigorik/em-http-request/issues/315). Only visible
259
259
  on very large clusters or when watching thousands of individual KV keys.
260
- * [ ] render_file might create an infinite recursion if a template includes itself indirectly.
260
+ * [ ] `render_file` might create an infinite recursion if a template includes itself indirectly.
261
261
 
262
262
  Please consult [CHANGELOG.md](CHANGELOG.md) for fixed bugs.
263
263
 
@@ -266,9 +266,9 @@ Please consult [CHANGELOG.md](CHANGELOG.md) for fixed bugs.
266
266
  * [ ] Hashi's Vault support
267
267
  * [ ] Implement automatic dynamic rate limit
268
268
  * [ ] More samples: apache, nginx, full website displaying consul information...
269
- * [ ] Optimize rendering speed at startup: an iteration is done very second by default, but it would be possible to speed
269
+ * [ ] Optimize rendering speed at start-up: an iteration is done very second by default, but it would be possible to speed
270
270
  up rendering by iterating with higher frequency until the first write of result has been performed.
271
- * [ ] Allow to tune bandwidth using a simple config file (while it should not be necessary for 90% of use-cases)
271
+ * [ ] Allow to tune bandwidth using a simple configuration file (while it should not be necessary for 90% of use-cases)
272
272
 
273
273
  ## Contributing
274
274
 
data/TemplateAPI.md CHANGED
@@ -95,7 +95,7 @@ Full example: [samples/consul_template.txt.erb](samples/consul_template.txt.erb)
95
95
 
96
96
  [List the instances](https://www.consul.io/api/health.html#list-nodes-for-service) of a service having the given
97
97
  optional tag. If no tag is specified, will return all instances of service. By default, it will return all the
98
- well services that are passing or not. An optional argument passing might be used to retrieve only passing instances.
98
+ services that are passing or not. An optional argument passing might be used to retrieve only passing instances.
99
99
 
100
100
  <details><summary>Examples</summary>
101
101
  <div class="samples">
@@ -92,19 +92,19 @@ optparse = OptionParser.new do |opts|
92
92
 
93
93
  def compute_signal(val, none_value)
94
94
  valid_signals = Signal.list.keys
95
- raise "Please #{val} specifiy a signal: #{valid_signals.inspect}" unless val
95
+ raise "Please specify a signal, use any of: #{valid_signals.inspect}" unless val
96
96
  return nil if val == none_value
97
- raise "Invalid signal, valid signals: #{valid_signals.inspect}" unless valid_signals.include? val
97
+ raise "Invalid signal #{val}, valid signals: #{valid_signals.inspect}" unless valid_signals.include? val
98
98
  val
99
99
  end
100
100
 
101
101
  opts.on('-K', '--sig-term=kill_signal', String,
102
- "Signal to sent to next --exec command on kill, default=#{cur_sig_term}") do |sig|
102
+ "Signal to send to next --exec command on kill, default=#{cur_sig_term}") do |sig|
103
103
  cur_sig_term = compute_signal(sig, nil)
104
104
  end
105
105
 
106
106
  opts.on('-R', '--sig-reload=reload_signal', String,
107
- "Signal to sent to next --exec command on reload (NONE supported), default=#{cur_sig_reload}") do |sig|
107
+ "Signal to send to next --exec command on reload (NONE supported), default=#{cur_sig_reload}") do |sig|
108
108
  cur_sig_reload = compute_signal(sig, 'NONE')
109
109
  end
110
110
 
@@ -1,5 +1,5 @@
1
1
  module Consul
2
2
  module Async
3
- VERSION = '1.0.10'.freeze
3
+ VERSION = '1.0.11'.freeze
4
4
  end
5
5
  end
@@ -4,8 +4,12 @@
4
4
  # CONSUL_TOOLS_PREFIX: prefix for the address of consul tools
5
5
  # CONSUL_TOOLS: comma sperated list of consul tools
6
6
  tools = (ENV['CONSUL_TOOLS'] || 'services').split(",")
7
- suffix = ENV['CONSUL_TOOLS_PREFIX'] || '-ui.html'
8
- prefix = ENV['CONSUL_TOOLS_SUFFIX'] || 'consul-'
7
+ tools_suffix = ENV['CONSUL_TOOLS_PREFIX'] || '-ui.html'
8
+ tools_prefix = ENV['CONSUL_TOOLS_SUFFIX'] || 'consul-'
9
+
10
+ dc_suffix = ENV['CONSUL_DC_SUFFIX'] || ''
11
+ dc_prefix = ENV['CONSUL_DC_PREFIX'] || '#'
12
+
9
13
  %><!DOCTYPE html>
10
14
  <html lang="en">
11
15
  <head>
@@ -13,24 +17,28 @@
13
17
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
14
18
  <meta name="description" content="Display Consul information"/>
15
19
  <meta name="author" content="Criteo"/>
16
- <meta http-equiv="refresh" content="<%= param('refresh', ENV['REFRESH'] || '600') %>"/>
17
20
  <title><%= param('title', 'Consul Real Time information') %></title>
18
21
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
19
- <!-- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> -->
20
22
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.11/css/all.css" integrity="sha384-p2jx59pefphTFIpeqCcISO9MdVfIm4pNnsL08A6v5vaQc4owkQqxMV8kg4Yvhaw/" crossorigin="anonymous">
21
23
  <link rel="stylesheet" href="css/style.css">
22
24
  </head>
23
25
  <body>
24
26
  <nav class="navbar navbar-expand-md navbar-dark bg-secondary">
25
- <a class="navbar-brand" href="#">Consul</a>
26
- <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
27
- <span class="navbar-brand">Consul</span>
28
- </button>
29
- <div class="collapse navbar-collapse" id="navbarsExampleDefault">
27
+ <div class="collapse navbar-collapse">
30
28
  <ul class="navbar-nav mr-auto">
29
+ <li class="nav-item dropdown">
30
+ <a class="navbar-brand dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
31
+ Consul
32
+ </a>
33
+ <div class="dropdown-menu" aria-labelledby="navbarDropdown">
34
+ <% datacenters.each do |dc| %>
35
+ <a class="dropdown-item" href="<%= dc_prefix + dc + dc_suffix %>"><%= dc %></a>
36
+ <% end %>
37
+ </div>
38
+ </li>
31
39
  <% tools.each do |tool| %>
32
40
  <li class="nav-item">
33
- <a class="nav-link" href="<%= prefix + tool + suffix %>"><%= tool.gsub('_', ' ').capitalize %></a>
41
+ <a class="nav-link" href="<%= tools_prefix + tool + tools_suffix %>"><%= tool.gsub('_', ' ').capitalize %></a>
34
42
  </li>
35
43
  <% end %>
36
44
  </ul>
@@ -1,4 +1,7 @@
1
- <% datasource = ENV['SERVICE_DATASOURCE'] || 'consul-template.json' %>
1
+ <% datasource = ENV['SERVICE_DATASOURCE'] || 'consul-template.json'
2
+ # Time to wait before reloading configuration again in seconds (0 = never)
3
+ refresh = ENV['REFRESH'] || '600' %>
4
+
2
5
  <%= render_file('common/header.html.erb', title: 'Services') %>
3
6
  <div class="main">
4
7
  <div class="row mx-0">
@@ -13,6 +16,11 @@
13
16
  </div>
14
17
  <div class="col-8 col-m-9">
15
18
  <h2 class="text-center" id="service-title"></h2>
19
+ <div class="progress">
20
+ <div id="service-progress-passing" status="passing" onclick="consulService.onClickFilter(this)" class="progress-status progress-bar bg-success" role="progressbar" style="width: 100%">passing</div>
21
+ <div id="service-progress-warning" status="warning" onclick="consulService.onClickFilter(this)" class="progress-status progress-bar bg-warning" role="progressbar" style="width: 0%">warning</div>
22
+ <div id="service-progress-critical" status="critical" onclick="consulService.onClickFilter(this)" class="progress-status progress-bar bg-danger" role="progressbar" style="width: 0%">critical</div>
23
+ </div>
16
24
  <div id="instances-wrapper">
17
25
  <div id="instances-list" class="list-group"></div>
18
26
  </div>
@@ -25,7 +33,7 @@
25
33
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
26
34
  <script src="js/service.js"></script>
27
35
  <script type="text/javascript">
28
- consulService = new ConsulService('<%= datasource %>');
36
+ consulService = new ConsulService('<%= datasource %>','<%= refresh %>');
29
37
  </script>
30
38
  </body>
31
39
  </html>
@@ -6,9 +6,9 @@
6
6
  # INSTANCE_EXCLUDE_TAG: Exclude instances having the given tag (default: canary)
7
7
  # EXCLUDE_SERVICES: comma-separated services to exclude (default: consul-agent-http,mesos-slave,mesos-agent-watcher)
8
8
 
9
- service_tag_filter = ENV['SERVICES_TAG_FILTER'] || 'http'
9
+ service_tag_filter = ENV['SERVICES_TAG_FILTER'] || nil
10
10
  instance_must_tag = ENV['INSTANCE_MUST_TAG'] || service_tag_filter
11
- instance_exclude_tag = ENV['INSTANCE_EXCLUDE_TAG'] || 'canary'
11
+ instance_exclude_tag = ENV['INSTANCE_EXCLUDE_TAG']
12
12
 
13
13
  # Services to hide
14
14
  services_blacklist = (ENV['EXCLUDE_SERVICES'] || 'consul-agent-http,mesos-slave,mesos-agent-watcher,mesos-exporter-slave').split(',')
@@ -42,11 +42,11 @@
42
42
  end
43
43
  backends = {}
44
44
  services(tag: service_tag_filter).each do |service_name, tags|
45
- if !services_blacklist.include?(service_name) && tags.include?(instance_must_tag)
45
+ if !services_blacklist.include?(service_name) && (instance_must_tag.nil? || tags.include?(instance_must_tag))
46
46
  the_backends = []
47
47
  service(service_name).sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] }.each do |snode|
48
48
  tags_of_instance = snode['Service']['Tags']
49
- if tags_of_instance.include?(instance_must_tag) && !tags_of_instance.include?(instance_exclude_tag)
49
+ if (instance_must_tag.nil? || tags_of_instance.include?(instance_must_tag)) && !tags_of_instance.include?(instance_exclude_tag)
50
50
  the_backends << snode if snode['Service']['Port']
51
51
  end
52
52
  end
@@ -85,5 +85,6 @@
85
85
  service[:instances] << server
86
86
  end
87
87
  end
88
- json = { services: json_backends}
88
+ json_datacenters = datacenters
89
+ json = { services: json_backends, datacenters: json_datacenters, generated_at: Time.now}
89
90
  %><%= JSON.pretty_generate(json) %>
@@ -38,7 +38,7 @@ h2 .fas {
38
38
  cursor: pointer;
39
39
  color: rgba( 0, 0, 0, 0.5);
40
40
  font-size: 1.5rem;
41
- transition: color .16s linear
41
+ transition: color .16s linear;
42
42
  }
43
43
 
44
44
  h2 .fas:hover {
@@ -55,3 +55,17 @@ h2 .fas:hover {
55
55
  padding: 5px;
56
56
  padding-left: 10px;
57
57
  }
58
+
59
+ .progress {
60
+ border-radius: 0px;
61
+ }
62
+
63
+ .progress-status {
64
+ transition: background-color .16s linear;
65
+ cursor: pointer;
66
+ }
67
+
68
+ .progress-deactivated {
69
+ background-color: #a5a5a5 !important;
70
+ color: #f1f1f1 !important;
71
+ }
@@ -1,27 +1,27 @@
1
1
  class ConsulService {
2
- constructor(ressourceURL) {
2
+ constructor(ressourceURL, refresh) {
3
3
  this.ressourceURL = ressourceURL;
4
4
  this.fetchRessource();
5
5
  this.serviceList = $("#service-list");
6
6
  this.serviceFilter = $("#service-filter");
7
- this.serviceFilter.keyup(this.filterService)
7
+ this.serviceFilter.keyup(this.filterService);
8
+ this.refresh = parseInt(refresh);
9
+ this.filterStatus = null;
8
10
  }
9
11
 
10
12
  fetchRessource() {
11
13
  $.ajax({url: "consul_template.json", cache: false, dataType: "json", sourceObject: this, success: function(result){
12
- if(this.sourceObject.data) {
13
- // For autoupdate
14
- } else {
15
- this.sourceObject.initRessource(result);
16
- }
14
+ consulService.initRessource(result);
17
15
  }});
18
16
  }
19
17
 
20
18
  initRessource(data) {
21
19
  this.data = data;
22
20
  this.reloadServiceList();
23
- var urlParam = new URL(location.href).searchParams.get('service')
24
- if(urlParam) {
21
+ console.log('Data generated at: ' + data['generated_at']);
22
+
23
+ var urlParam = new URL(location.href).searchParams.get('service');
24
+ if (urlParam) {
25
25
  var nodes = document.getElementById('service-list').childNodes;
26
26
  for(var i in nodes) {
27
27
  if($(nodes[i]).html() == urlParam) {
@@ -32,6 +32,10 @@ class ConsulService {
32
32
  } else {
33
33
  this.selectService(document.getElementById('service-list').firstElementChild);
34
34
  }
35
+
36
+ if(this.refresh > 0) {
37
+ setTimeout(this.fetchRessource, this.refresh * 1000);
38
+ }
35
39
  }
36
40
 
37
41
  reloadServiceList() {
@@ -62,6 +66,38 @@ class ConsulService {
62
66
  this.updateURL();
63
67
  }
64
68
 
69
+ onClickFilter(source) {
70
+ var status = $(source).attr('status');
71
+ this.filterStatus = (this.filterStatus == status) ? null : status;
72
+ this.filterInstances();
73
+ }
74
+
75
+ filterInstances() {
76
+ $('.progress-status').each(function() {
77
+ var status = $(this).attr('status');
78
+ if (consulService.filterStatus == null) {
79
+ $(this).removeClass('progress-deactivated');
80
+ } else if(consulService.filterStatus == status) {
81
+ $(this).removeClass('progress-deactivated');
82
+ } else {
83
+ $(this).addClass('progress-deactivated');
84
+ }
85
+ })
86
+ $('#instances-list').children('div').each(function() {
87
+ var status = $(this).attr('status');
88
+ if (consulService.filterStatus == null) {
89
+ $(this).removeClass('d-none');
90
+ $(this).addClass('d-block');
91
+ } else if (consulService.filterStatus == status) {
92
+ $(this).removeClass('d-none');
93
+ $(this).addClass('d-block');
94
+ } else {
95
+ $(this).removeClass('d-block');
96
+ $(this).addClass('d-none');
97
+ }
98
+ })
99
+ }
100
+
65
101
  updateURL() {
66
102
  var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
67
103
  newUrl += '?service=' + $(this.selectedService).html();
@@ -82,7 +118,9 @@ class ConsulService {
82
118
 
83
119
  displayService(service) {
84
120
  $("#service-title").html(service['name']);
85
- $("#instances-list").html("")
121
+ $("#instances-list").html("");
122
+
123
+ var serviceStatus = {};
86
124
 
87
125
  for (var key in service['instances']) {
88
126
  var instance = service['instances'][key];
@@ -92,26 +130,54 @@ class ConsulService {
92
130
  serviceHtml.appendChild(serviceTitleGenerator(instance));
93
131
  serviceHtml.appendChild(tagsGenerator(instance));
94
132
  serviceHtml.appendChild(checksStatusGenerator(instance));
133
+ var state = nodeState(instance);
134
+ serviceHtml.setAttribute('status', state);
135
+ serviceStatus[state] = (serviceStatus[state] || 0) + 1;
136
+ serviceStatus['total'] = (serviceStatus['total'] || 0) + 1;
95
137
 
96
138
  $("#instances-list").append(serviceHtml);
97
139
  }
98
140
 
141
+ $('#service-progress-passing').css('width', (serviceStatus['passing'] || 0) / serviceStatus['total'] * 100 + '%')
142
+ $('#service-progress-warning').css('width', (serviceStatus['warning'] || 0) / serviceStatus['total'] * 100 + '%')
143
+ $('#service-progress-critical').css('width', (serviceStatus['critical'] || 0) / serviceStatus['total'] * 100 + '%')
144
+
99
145
  resizeWrapper('instances-wrapper', 'instances-list');
100
146
  $('#instances-list .list-group-item').resize(resizeAll);
101
147
  }
102
148
  }
103
149
 
150
+ function nodeState(instance) {
151
+ status='passing';
152
+ for (var checkKey in instance.checks) {
153
+ switch(instance.checks[checkKey]['status']) {
154
+ case 'passing': break;
155
+ case 'warning': status='warning'; break;
156
+ case 'critical': return 'critical'; break;
157
+ }
158
+ }
159
+ return status;
160
+ }
161
+
162
+ supported_protocols = ['https', 'http', 'sftp', 'ftp', 'ssh', 'telnet']
163
+
104
164
  function serviceTitleGenerator(instance) {
105
- var protocol = 'http://';
106
- if(instance.tags.includes('https')) {
107
- protocol = 'https://';
165
+ var protocol = null;
166
+ for (i in supported_protocols) {
167
+ var protoc = supported_protocols[i]
168
+ if (instance.tags.includes(protoc)) {
169
+ protocol = protoc + '://';
170
+ break;
171
+ }
108
172
  }
109
173
 
110
174
  var htmlTitle = document.createElement('h5');
111
175
 
112
176
  var instanceLink = document.createElement('a');
113
- instanceLink.setAttribute('href', protocol + instance.name + ':' + instance.port);
114
- instanceLink.setAttribute('target', '_blank');
177
+ if (protocol != null) {
178
+ instanceLink.setAttribute('href', protocol + instance.name + ':' + instance.port);
179
+ instanceLink.setAttribute('target', '_blank');
180
+ }
115
181
  instanceLink.appendChild(document.createTextNode(instance.name + ':' + instance.port));
116
182
  htmlTitle.appendChild(instanceLink);
117
183
 
@@ -177,7 +243,17 @@ function checksStatusGenerator(instance) {
177
243
  var td2 = document.createElement('td');
178
244
  var fieldName = dataToDisplay[index].replace(/\b\w/g, l => l.toUpperCase());
179
245
  td1.appendChild(document.createTextNode(fieldName + ': '));
180
- td2.appendChild(document.createTextNode(instance.checks[checkKey][dataToDisplay[index]]));
246
+ var target = td2
247
+ if (index != 1) {
248
+ target = document.createElement('div');
249
+ target.setAttribute("class", "check-notes")
250
+ } else {
251
+ // Notes are rendered as plain text
252
+ target = document.createElement('pre');
253
+ target.setAttribute("class", "check-output")
254
+ }
255
+ target.appendChild(document.createTextNode(instance.checks[checkKey][dataToDisplay[index]]));
256
+ td2.appendChild(target)
181
257
  tr.appendChild(td1);
182
258
  tr.appendChild(td2);
183
259
  notes.appendChild(tr);
@@ -57,7 +57,7 @@ if key_to_display
57
57
  <code><%
58
58
  # catch_errors: true will return nil if data cannot be converted to JSON
59
59
  json = kv(key_to_display).get_value_json(catch_errors: true)
60
- %><%= (json ? jERB::Util.html_escape(json) : 'No Valid JSON Data') %></code>
60
+ %><%= (json ? ERB::Util.html_escape(json) : 'No Valid JSON Data') %></code>
61
61
  </div>
62
62
  <%
63
63
  end
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.0.10
4
+ version: 1.0.11
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-05-04 00:00:00.000000000 Z
11
+ date: 2018-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -135,7 +135,6 @@ extra_rdoc_files:
135
135
  - TemplateAPI.md
136
136
  files:
137
137
  - ".gitignore"
138
- - ".gitreview"
139
138
  - ".rspec"
140
139
  - ".rubocop.yml"
141
140
  - ".ruby_app"
data/.gitreview DELETED
@@ -1,5 +0,0 @@
1
- [gerrit]
2
- host=review.criteois.lan
3
- port=29418
4
- project=ruby-gems/consul-templaterb
5
- defaultbranch=master