From 592f0fbe416d8adaaabe436ed2b4ad481981b8db Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 18 Nov 2023 19:56:03 +0100 Subject: [PATCH 1/4] fix: add templating support in configuration Refs: #15 --- shard.lock | 3 +++ shard.yml | 2 ++ src/config.cr | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) 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| From 9f0902d91d3ea098a9d4be2d109418ee728a0519 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 18 Nov 2023 20:03:57 +0100 Subject: [PATCH 2/4] ci: add missing dependencies --- .drone.yml | 9 +++++++-- shard.lock | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index ae62da4..4b41c0d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,11 +13,16 @@ steps: path: /_cache commands: - pwd - - apt-get update && - apt-get install -y cmake g++ libevent-dev libpcre3-dev libyaml-dev + - | + apt-get update && \ + apt-get install -y \ + cmake g++ \ + libevent-dev libpcre3-dev \ + libyaml-dev liblzma-dev - shards install - shards build --production --static - strip bin/mfm + - ./bin/mfm --version - mkdir -p /_cache/bin - cp -r bin/mfm /_cache/bin/$PACKAGE_BASENAME diff --git a/shard.lock b/shard.lock index 8d43fbc..c0f0724 100644 --- a/shard.lock +++ b/shard.lock @@ -3,6 +3,7 @@ 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 From e6a9d0117504083c0ed9ee5a30c90414fc2869d5 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 18 Nov 2023 20:19:51 +0100 Subject: [PATCH 3/4] ci: bump crystal version --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4b41c0d..a980769 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,7 +5,7 @@ name: default steps: - name: build:binary - image: crystallang/crystal:1.7.3 + image: crystallang/crystal:1.10.1 environment: PACKAGE_BASENAME: mfm_linux_amd64 volumes: From 3c4e4271b226d0d08939b6c1cc15db079c92ed0c Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 18 Nov 2023 23:23:39 +0100 Subject: [PATCH 4/4] ci: switch to alpine for static linking --- .drone.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index a980769..8999d06 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,7 +5,7 @@ name: default steps: - name: build:binary - image: crystallang/crystal:1.10.1 + image: crystallang/crystal:1.10.1-alpine environment: PACKAGE_BASENAME: mfm_linux_amd64 volumes: @@ -13,12 +13,12 @@ steps: path: /_cache commands: - pwd - - | - apt-get update && \ - apt-get install -y \ - cmake g++ \ - libevent-dev libpcre3-dev \ - libyaml-dev liblzma-dev + # - | + # apt-get update && \ + # apt-get install -y \ + # cmake g++ \ + # libevent-dev libpcre3-dev \ + # libyaml-dev liblzma-dev - shards install - shards build --production --static - strip bin/mfm