consult 1.0.0.pre → 1.0.0.pre1
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 +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +7 -0
- data/lib/consult/template.rb +21 -3
- 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: 1c7a54f7fb838f2f50a3553e2f798b75d569cf227c4c9d927d2185d4b597f882
|
4
|
+
data.tar.gz: be503dd900d460f14d8ae2ecaddd6eec05193859b2668d32762dd62e3e2f4cb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f736a61ae78df99d70d778ec0a61bbaf6b702cc2e7d7b5e10f4a4c40682dd21cb72975cb49d6db28b502334b3027c793b17caa2b3a818f20fb05e52389a84a55
|
7
|
+
data.tar.gz: e786886e41c2a6c81b169c4d781465e422bae03b059b65dd6b156c8d30c2530c773157d752a150d569e514a56e6ccfa05b537f498d9bcc8c1078bdb336109688
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
* Development: adjust require's to be able to run CLI from any folder
|
10
10
|
* Enable defining vars at the env block level, rather than only on template blocks
|
11
11
|
* Create directories for rendered files as needed
|
12
|
+
* Add the `skip_missing_template` config for templates
|
12
13
|
|
13
14
|
#### 0.11.0
|
14
15
|
|
data/README.md
CHANGED
@@ -98,6 +98,13 @@ test:
|
|
98
98
|
vars:
|
99
99
|
test_specific_key: and_the_value
|
100
100
|
|
101
|
+
extra_test_config:
|
102
|
+
# normally there's an error for missing templates, but this can be allowed via config
|
103
|
+
skip_missing_template: true
|
104
|
+
# config files are also processed through ERB, so paths can be made dynamic
|
105
|
+
path: config/templates/<%= ENV['extra_test_file'] %>.yml
|
106
|
+
dest: config/extra_test_config.yml
|
107
|
+
|
101
108
|
production:
|
102
109
|
# vars can be defined at the environment level, which are available to these templates
|
103
110
|
vars:
|
data/lib/consult/template.rb
CHANGED
@@ -19,6 +19,10 @@ module Consult
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def render(save: true)
|
22
|
+
if contents.empty? && @config[:skip_missing_template]
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
22
26
|
# Attempt to render
|
23
27
|
renderer = ERB.new(contents, nil, '-')
|
24
28
|
result = renderer.result(binding)
|
@@ -76,20 +80,34 @@ module Consult
|
|
76
80
|
|
77
81
|
# Concatenate all the source templates together, in the order provided
|
78
82
|
def contents
|
79
|
-
ordered_locations.map do |location|
|
83
|
+
@_contents ||= ordered_locations.map do |location|
|
80
84
|
location.to_s.start_with?('consul') ? consul_contents(location) : disk_contents(location)
|
81
|
-
end.join
|
85
|
+
end.compact.join
|
82
86
|
end
|
83
87
|
|
84
88
|
def consul_contents(location)
|
85
89
|
[@config[location]].compact.flatten.map do |key|
|
86
|
-
Diplomat::Kv.get(key,
|
90
|
+
Diplomat::Kv.get(key, {}, :reject, :return).force_encoding 'utf-8'
|
91
|
+
rescue Diplomat::KeyNotFound
|
92
|
+
if @config[:skip_missing_template]
|
93
|
+
STDERR.puts "Consult: Skipping missing template: #{name}"
|
94
|
+
next
|
95
|
+
end
|
96
|
+
|
97
|
+
raise
|
87
98
|
end.join
|
88
99
|
end
|
89
100
|
|
90
101
|
def disk_contents(location)
|
91
102
|
[public_send(location)].compact.flatten.map do |file_path|
|
92
103
|
File.read file_path, encoding: 'utf-8'
|
104
|
+
rescue Errno::ENOENT
|
105
|
+
if @config[:skip_missing_template]
|
106
|
+
STDERR.puts "Consult: Skipping missing template: #{name}"
|
107
|
+
next
|
108
|
+
end
|
109
|
+
|
110
|
+
raise
|
93
111
|
end.join
|
94
112
|
end
|
95
113
|
end
|
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: 1.0.0.
|
4
|
+
version: 1.0.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Fraser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diplomat
|