consult 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +13 -7
- data/docker-compose.yml +2 -2
- data/lib/consult.rb +0 -1
- data/lib/consult/template.rb +35 -4
- data/lib/consult/utilities.rb +1 -0
- data/lib/consult/version.rb +1 -1
- 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: 371b66af8be47b598b8ee428856c17d35864b5ba93b3bff8ad0852c4d403d2fe
|
4
|
+
data.tar.gz: ce70cfa1f22a21d6255ae2fd1a867b2950765ca5c3b8b3c4f8090aab8f0c28d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f72c7410f792f22c1bdc4d095b9f2fb122943625f2be6876461f692acd378fbd4bce6ce14797fe387d59d8ffaaf827612b3a7fb908d880a07b2933dddf294d03
|
7
|
+
data.tar.gz: f19a08e8ec11f404c82c6344885c36cc9346d04fbdaa7de8fdb9ddb3fe7059d1cc4c7d4c472a2a2ad41a642a87e338b5aa49a4eff36b0a19cd795dc29b48ee9f
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
#### 0.8.0
|
2
|
+
|
3
|
+
* Add support for multiple sources for a single template ([#14](https://github.com/veracross/consult/pull/14))
|
4
|
+
* Add support for Consul-sourced templates ([#15](https://github.com/veracross/consult/pull/15))
|
5
|
+
* Don't crash on rendering errors ([#16](https://github.com/veracross/consult/pull/16))
|
6
|
+
|
1
7
|
#### 0.7.3
|
2
8
|
|
3
9
|
* Add `key` function to templates to pull kv data from Consul
|
data/README.md
CHANGED
@@ -88,14 +88,20 @@ test:
|
|
88
88
|
dest: config/secrets.yml
|
89
89
|
|
90
90
|
production:
|
91
|
-
# example: override vault token in production
|
92
|
-
vault:
|
93
|
-
token: 1397af7aede2-8923-412d-3eb9-8fcd5aed
|
94
91
|
templates:
|
95
|
-
#
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
# You can concatenate multiple files together
|
93
|
+
my_config:
|
94
|
+
paths:
|
95
|
+
- config/templates/one.yml
|
96
|
+
- config/templates/two.yml
|
97
|
+
dest: config/my_config.yml
|
98
|
+
|
99
|
+
# Templates can come from Consul
|
100
|
+
your_config:
|
101
|
+
consul_keys:
|
102
|
+
- some/consul/key
|
103
|
+
- another/consul/key
|
104
|
+
dest: config/your_config.txt
|
99
105
|
```
|
100
106
|
|
101
107
|
### Templates
|
data/docker-compose.yml
CHANGED
data/lib/consult.rb
CHANGED
data/lib/consult/template.rb
CHANGED
@@ -15,18 +15,28 @@ module Consult
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def render(save: true)
|
18
|
-
|
18
|
+
# Attempt to render
|
19
|
+
renderer = ERB.new(contents, nil, '-')
|
19
20
|
result = renderer.result(binding)
|
20
21
|
|
21
22
|
File.open(dest, 'w') { |f| f << result } if save
|
22
23
|
result
|
23
24
|
rescue StandardError => e
|
24
|
-
puts "Error rendering template: #{name}"
|
25
|
-
|
25
|
+
STDERR.puts "Error rendering template: #{name}"
|
26
|
+
STDERR.puts e
|
27
|
+
nil
|
26
28
|
end
|
27
29
|
|
28
30
|
def path
|
29
|
-
resolve @config
|
31
|
+
resolve @config[:path]
|
32
|
+
end
|
33
|
+
|
34
|
+
def paths
|
35
|
+
@config.fetch(:paths, []).map { |path| resolve(path) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def vars
|
39
|
+
@config[:vars]
|
30
40
|
end
|
31
41
|
|
32
42
|
def dest
|
@@ -42,5 +52,26 @@ module Consult
|
|
42
52
|
return true if !config.key?(:ttl) || !dest.exist?
|
43
53
|
dest.mtime < (Time.now - @config[:ttl].to_i)
|
44
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
# Concatenate all the source templates together, in the order provided
|
59
|
+
# Disk contents go first
|
60
|
+
def contents
|
61
|
+
disk_contents + consul_contents
|
62
|
+
end
|
63
|
+
|
64
|
+
def consul_contents
|
65
|
+
[@config[:consul_key], @config[:consul_keys]].compact.flatten.map do |key|
|
66
|
+
Diplomat::Kv.get(key, options: nil, not_found: :return, found: :return)
|
67
|
+
end.join
|
68
|
+
end
|
69
|
+
|
70
|
+
# Concatenate all the source templates together, in the order provided
|
71
|
+
def disk_contents
|
72
|
+
[path, paths].compact.flatten.map do |file_path|
|
73
|
+
File.read file_path, encoding: 'utf-8'
|
74
|
+
end.join
|
75
|
+
end
|
45
76
|
end
|
46
77
|
end
|
data/lib/consult/utilities.rb
CHANGED
data/lib/consult/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consult
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Fraser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|