From 6bd1abb504e7ed41ecba2cf43d598158ea38ecb8 Mon Sep 17 00:00:00 2001 From: Karolis2011 Date: Sun, 24 Aug 2025 19:46:43 +0300 Subject: [PATCH] Refactor load_config and load_host_config: streamline configuration loading and improve structure --- lib/std.alloy | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/std.alloy b/lib/std.alloy index fd73412..c83f29b 100644 --- a/lib/std.alloy +++ b/lib/std.alloy @@ -28,14 +28,8 @@ declare "fmt_repository_path" { } } -declare "load_host_config" { - argument "host" { - optional = true - comment = "The host to load the configuration for" - default = sys.env("GCLOUD_FM_COLLECTOR_ID") - } - - argument "config_file" { +declare "load_config" { + argument "config_file" { optional = false comment = "The path to the configuration file" } @@ -58,6 +52,34 @@ declare "load_host_config" { } export "config" { - value = encoding.from_yaml(remote.http.config_file.content)[argument.host.value] + value = remote.http.config_file.content + } +} + +declare "load_host_config" { + argument "host" { + optional = true + comment = "The host to load the configuration for" + default = sys.env("GCLOUD_FM_COLLECTOR_ID") + } + + argument "config_file" { + optional = false + comment = "The path to the configuration file" + } + + argument "repository" { + optional = true + comment = "The repository to use for loading the configuration" + default = "https://git.kkarolis.lt/karolis/Alloy/" + } + + load_config "remote" { + config_file = argument.config_file.value + repository = argument.repository.value + } + + export "config" { + value = encoding.from_yaml(load_config.remote.config)[argument.host.value] } }