diff --git a/shard.lock b/shard.lock index 308912c..8d43fbc 100644 --- a/shard.lock +++ b/shard.lock @@ -1,5 +1,8 @@ version: 2.0 shards: + crinja: + git: https://github.com/straight-shoota/crinja.git + version: 0.8.1 shellwords: git: https://github.com/sztheory/shellwords-crystal.git version: 0.1.0 diff --git a/shard.yml b/shard.yml index 314293a..746f2c8 100644 --- a/shard.yml +++ b/shard.yml @@ -18,6 +18,8 @@ targets: # Short description of gx-vault dependencies: + crinja: + github: straight-shoota/crinja shellwords: github: szTheory/shellwords-crystal diff --git a/src/config.cr b/src/config.cr index 7a71c9f..913c066 100644 --- a/src/config.cr +++ b/src/config.cr @@ -3,6 +3,8 @@ # SPDX-FileCopyrightText: 2023 Glenn Y. Rolland # Copyright © 2023 Glenn Y. Rolland +require "crinja" + require "./filesystems" module GX @@ -81,7 +83,11 @@ module GX end private def load_filesystems(config_path : String) - yaml_data = YAML.parse(File.read(config_path)) + file_data = File.read(config_path) + # FIXME: render template on a value basis (instead of global) + file_patched = Crinja.render(file_data, {"env" => ENV.to_h}) + + yaml_data = YAML.parse(file_patched) vaults_data = yaml_data["filesystems"].as_a vaults_data.each do |filesystem_data|