consul-templaterb 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ <%= render_file 'common/header.html.erb' %>
2
+ <% path = ENV['kv_path'] || 'services-data' %>
3
+ <% require 'base64'
4
+ require 'json'
5
+ require 'date'
6
+ %>
7
+ <main role="main" class="container">
8
+ <div>
9
+ <h1>Show all keys under hierarchy <%= path %></h1>
10
+ <div id="accordion">
11
+ <% kv(path, recurse:true).each do |tuple|
12
+ key = tuple['Key']
13
+ val = "NO_VALUE"
14
+ if !tuple['Value'].nil?
15
+ begin
16
+ val = Base64.decode64(tuple['Value'])
17
+ rescue StdError => e
18
+ val = "#{e.inspect} for tuple['Value']"
19
+ end
20
+ end
21
+ %>
22
+ <div class="card">
23
+ <div class="card-header" id="heading-<%= key %>">
24
+ <h5 class="mb-0">
25
+ <a href="#<%= key %>" class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse-<%= key %>" aria-expanded="true" aria-controls="collapse-<%= key %>">
26
+ <%= key %>
27
+ </a>
28
+ </h5>
29
+ <div id="collapse-<%= key %>" class="collapse" aria-labelledby="heading-<%= key %>" data-parent="#accordion">
30
+ <div class="card-body">
31
+ <pre class="pre-scrollable"><%= val %></pre>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ <% end %>
37
+ </div>
38
+ <%= render_file 'common/footer.html.erb' %>
@@ -0,0 +1,17 @@
1
+ <%= render_file 'common/header.html.erb' %>
2
+ <h1 id="nodes">List all nodes for DC, sorted by name</h1>
3
+ <ul>
4
+ <% nodes.sort {|a,b| a['Node'] <=> b['Node'] }.each do |snode|
5
+ %> <li id="node_#{snode['ID']"><a href="ssh://<%= snode['Address']%>"><%= snode['Address'].ljust(16) %></a> <%= snode['Node'] %><%
6
+ snode['Meta'].each do |k,v|
7
+ if v && !v.empty?
8
+ %>
9
+ <span class="badge badge-pill badge-primary float-right"><%= k %>:&nbsp;<%= v%></span>
10
+ <%
11
+ end
12
+ end if snode['Meta']
13
+ %>
14
+ </li>
15
+ <% end %>
16
+ </ul>
17
+ <%= render_file 'common/footer.html.erb' %>
@@ -0,0 +1,89 @@
1
+ <%
2
+ # This template can be configure the following way with environment variables
3
+ # Environment variables to filter services/instances
4
+ # SERVICES_TAG_FILTER: basic tag filter for service (default HTTP)
5
+ services_tag_filter = ENV['SERVICES_TAG_FILTER']
6
+ def status_to_class(status)
7
+ if status == 'passing'
8
+ 'success'
9
+ elsif status == 'warning'
10
+ 'warning'
11
+ elsif status == 'critical'
12
+ 'danger'
13
+ else
14
+ 'info'
15
+ end
16
+ end
17
+ %>
18
+ <%= render_file 'common/header.html.erb' %>
19
+ <% require 'base64'
20
+ require 'json'
21
+ require 'date'
22
+ %>
23
+ <nav>
24
+ <ul>
25
+ <li><a href="#datacenters">DataCenters</a></li>
26
+ <li><a href="#list_services">List of services</a></li>
27
+ <li><a href="#services">Services with instances</a></li>
28
+ <li><a href="#nodes">All Nodes</a></li>
29
+ <li><a href="#kv">Key/Value Store</a></li>
30
+ </ul>
31
+ </nav>
32
+ <h1 id="datacenters">List of all datacenters</h1>
33
+ <ul>
34
+ <% datacenters.each do |dc| %>
35
+ <li id="dc_<%=dc %>%"><%= dc %> with <%= services(dc:dc).keys.count %> services, <%= nodes(dc:dc).count %> nodes</li>
36
+ <% end %>
37
+ </ul>
38
+
39
+ <h1 id="list_services">List of all services in current DC</h1>
40
+ <ul>
41
+ <% services.each do |service_name, tags|
42
+ %>
43
+ <li><a href="#service_<%= service_name %>"><%= service_name %></a> <%= tags.sort %></li>
44
+ <% end %>
45
+ </ul>
46
+
47
+ <h1 id="services">List all services instances sorted by node name</h1>
48
+ <% services.each do |service_name, tags|
49
+ %><h2 id="service_<%= service_name %>" title="<%= tags %>"><%= service_name %> <a class="qlink" href="#service_<%= service_name %>">&#128279;</a></h2>
50
+ <ul>
51
+ <% service(service_name).sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] }.each do |snode|
52
+ tags = snode['Service']['Tags'].sort
53
+ addr = snode['Node']['Address']
54
+ port_num = snode['Service']['Port'].to_i
55
+ port = port_num && port_num > 0 ? ":#{port_num}" : ''
56
+ url = if tags.include? 'https'
57
+ "https://#{addr}#{port}"
58
+ elsif tags.include? 'http'
59
+ "http://#{addr}#{port}"
60
+ elsif tags.include? 'ftp'
61
+ "ftp://#{addr}#{port}"
62
+ else
63
+ nil
64
+ end
65
+ %><li><a <%= url ? "href=\"#{url}\"" : nil %>><%=
66
+ snode['Node']['Node'] %><%= port %></a>
67
+ <span class="tags"><%= snode['Service']['Tags'].sort %></tag>
68
+ <span class="statuses"><%
69
+ snode['Checks'].each do |c| %> <span title="<%= c['Name']%>" class="<%= c['Status'] %>"><%= c['Status']
70
+ %></span><% end if snode['Checks'] %></span></li>
71
+ <% end%>
72
+ </ul>
73
+ <% end%>
74
+
75
+
76
+ <h1 id="nodes">List all nodes for DC, sorted by name</h1>
77
+ <ul>
78
+ <% nodes.sort {|a,b| a['Node'] <=> b['Node'] }.each do |snode|
79
+ %> <li id="node_#{snode['ID']"><%= snode['Address'].ljust(16) %> <%= snode['Node'] %></li>
80
+ <% end %>
81
+ </ul>
82
+
83
+ <h1 id="kv">KV of Current DC</h1>
84
+ <ul>
85
+ <% kv(keys:true).each do |key|
86
+ %><li id="kv_#{key}"><%= key %></li>
87
+ <% end %>
88
+ </ul>
89
+ <%= render_file 'common/footer.html.erb' %>
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: consul-templaterb
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - SRE Core Services
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: em-http-request
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec_junit_formatter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-junit-formatter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A ruby implementation of Consul Template with support of erb templating
126
+ email:
127
+ - sre-core-services@criteo.com
128
+ executables:
129
+ - consul-templaterb
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".gitreview"
135
+ - ".rspec"
136
+ - ".rubocop.yml"
137
+ - ".ruby_app"
138
+ - ".travis.yml"
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/consul-templaterb
144
+ - consul-templaterb.gemspec
145
+ - lib/consul/async/consul_endpoint.rb
146
+ - lib/consul/async/consul_template.rb
147
+ - lib/consul/async/consul_template_engine.rb
148
+ - lib/consul/async/consul_template_render.rb
149
+ - lib/consul/async/process_handler.rb
150
+ - lib/consul/async/utilities.rb
151
+ - lib/consul/async/version.rb
152
+ - samples/checks.html.erb
153
+ - samples/common/footer.html.erb
154
+ - samples/common/header.html.erb
155
+ - samples/consul_template.html.erb
156
+ - samples/consul_template.json.erb
157
+ - samples/consul_template.txt.erb
158
+ - samples/consul_template.xml.erb
159
+ - samples/criteo/haproxy.cfg.erb
160
+ - samples/criteo_choregraphies.html.erb
161
+ - samples/ha_proxy.cfg.erb
162
+ - samples/keys.html.erb
163
+ - samples/nodes.html.erb
164
+ - samples/services.html.erb
165
+ homepage: https://github.com/criteo/consul-templaterb
166
+ licenses:
167
+ - Apache v2
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.7.3
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Implementation of Consul template using Ruby and .erb templating language
189
+ test_files: []