consult 0.11.0.pre → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +7 -0
- data/lib/consult/cli.rb +6 -1
- data/lib/consult/template.rb +12 -4
- data/lib/consult/version.rb +1 -1
- data/lib/consult.rb +15 -4
- 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: a0cf440030413aa3a130de66a00f1b349a232dfe0a56a8517c5fda6590bef31a
|
4
|
+
data.tar.gz: 63e51ae272e2504f3be979d10a4d46c2d954210b68c6cb2584a481862f80f8c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41891ee20a9018c7db6ed5c366a87273e5b58102813f3e7db6ff6c906b4ed7c390eaa898fdb6a5c9a849f399ca19753ca6c2541e20945a81ff309a2aa3a21e5b
|
7
|
+
data.tar.gz: b3ad3e1a3d688292eecdbd2e2984fa347b5bae91024d9a5f65f2ec5ca340326ae336a8f9d0693c0c7978960912fb0c35d3eb2f5595b90733ecc218e54e65e48c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
#### Unreleased
|
2
2
|
|
3
|
+
#### 1.0.0
|
4
|
+
|
5
|
+
* Stop with error when force rendering and no template is found
|
6
|
+
* Remove non-functional short verbosity argument
|
7
|
+
* Add `--version` option to show the version
|
8
|
+
* Better logging for template rendering status, errors, and config (verbose mode)
|
9
|
+
* Development: adjust require's to be able to run CLI from any folder
|
10
|
+
* Enable defining vars at the env block level, rather than only on template blocks
|
11
|
+
* Create directories for rendered files as needed
|
12
|
+
|
3
13
|
#### 0.11.0
|
4
14
|
|
5
15
|
* Enable support for Ruby 3.1 ([#36](https://github.com/veracross/consult/pull/36))
|
data/README.md
CHANGED
@@ -94,8 +94,15 @@ test:
|
|
94
94
|
secrets:
|
95
95
|
path: config/templates/secrets.yml
|
96
96
|
dest: config/secrets.yml
|
97
|
+
# vars can be defined on a per-template basis
|
98
|
+
vars:
|
99
|
+
test_specific_key: and_the_value
|
97
100
|
|
98
101
|
production:
|
102
|
+
# vars can be defined at the environment level, which are available to these templates
|
103
|
+
vars:
|
104
|
+
hello: world
|
105
|
+
|
99
106
|
templates:
|
100
107
|
# You can concatenate multiple files together
|
101
108
|
my_config:
|
data/lib/consult/cli.rb
CHANGED
@@ -38,9 +38,14 @@ module Consult
|
|
38
38
|
opts[:force_render] = arg
|
39
39
|
end
|
40
40
|
|
41
|
-
o.on '
|
41
|
+
o.on '--quiet', FalseClass, 'Silence output' do |arg|
|
42
42
|
opts[:verbose] = arg
|
43
43
|
end
|
44
|
+
|
45
|
+
o.on '--version', 'Show version' do
|
46
|
+
puts "Consult #{Consult::VERSION}"
|
47
|
+
exit 0
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
46
51
|
@parser.on_tail "-h", "--help", "Show help" do
|
data/lib/consult/template.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'fileutils'
|
4
|
+
require_relative 'template_functions'
|
5
|
+
require_relative '../support/hash_extensions'
|
4
6
|
|
5
7
|
module Consult
|
6
8
|
class Template
|
@@ -21,12 +23,18 @@ module Consult
|
|
21
23
|
renderer = ERB.new(contents, nil, '-')
|
22
24
|
result = renderer.result(binding)
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
puts "Consult: Rendering #{name}" + (save ? " to #{dest} ..." : "...") if verbose?
|
27
|
+
|
28
|
+
if save
|
29
|
+
FileUtils.mkdir_p(dest.dirname) unless dest.dirname.exist?
|
30
|
+
File.open(dest, 'wb') { |f| f << result }
|
31
|
+
end
|
32
|
+
|
26
33
|
result
|
27
34
|
rescue StandardError => e
|
28
35
|
STDERR.puts "Error rendering template: #{name}"
|
29
36
|
STDERR.puts e
|
37
|
+
STDERR.puts e.backtrace if verbose?
|
30
38
|
nil
|
31
39
|
end
|
32
40
|
|
@@ -39,7 +47,7 @@ module Consult
|
|
39
47
|
end
|
40
48
|
|
41
49
|
def vars
|
42
|
-
@config[:vars]
|
50
|
+
@config[:env_vars].to_h.deep_merge @config[:vars].to_h
|
43
51
|
end
|
44
52
|
|
45
53
|
def dest
|
data/lib/consult/version.rb
CHANGED
data/lib/consult.rb
CHANGED
@@ -6,9 +6,9 @@ require 'erb'
|
|
6
6
|
require 'vault'
|
7
7
|
require 'diplomat'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
require_relative './consult/version'
|
10
|
+
require_relative './consult/utilities'
|
11
|
+
require_relative './consult/template'
|
12
12
|
require_relative './support/hash_extensions'
|
13
13
|
|
14
14
|
module Consult
|
@@ -24,21 +24,32 @@ module Consult
|
|
24
24
|
root directory: config_dir
|
25
25
|
yaml = root.join('config', 'consult.yml')
|
26
26
|
|
27
|
+
if verbose
|
28
|
+
puts "Consult: Loading config from #{yaml}"
|
29
|
+
end
|
30
|
+
|
27
31
|
@all_config = if yaml.exist?
|
28
32
|
if Gem::Version.new(YAML::VERSION) < Gem::Version.new('4.0')
|
29
33
|
YAML.safe_load(ERB.new(yaml.read).result, [], [], true, symbolize_names: true).to_h
|
30
34
|
else
|
31
35
|
YAML.safe_load(ERB.new(yaml.read).result, aliases: true, symbolize_names: true).to_h
|
32
36
|
end
|
37
|
+
else
|
38
|
+
STDERR.puts "Consult: No config file found at #{root} -> #{yaml}"
|
33
39
|
end
|
34
40
|
|
35
41
|
@all_config ||= {}
|
36
42
|
|
37
43
|
@config = @all_config[:shared].to_h.deep_merge @all_config[env&.to_sym].to_h
|
38
|
-
@templates = @config[:templates]&.map { |name, config| Template.new(name, config.merge(verbose: verbose)) } || []
|
44
|
+
@templates = @config[:templates]&.map { |name, config| Template.new(name, config.merge(verbose: verbose).merge(env_vars: @config[:vars])) } || []
|
39
45
|
|
40
46
|
@force_render = force_render
|
41
47
|
|
48
|
+
if @templates.empty? && @force_render
|
49
|
+
STDERR.puts "Consult: No template was found for env #{env.inspect} with forced rendering (re-run with `--no-force` if this is acceptable)"
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
|
42
53
|
configure_consul
|
43
54
|
configure_vault
|
44
55
|
end
|
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: 1.0.0.pre
|
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-
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diplomat
|