From 8b696574fa00f9ec88a53a484956ae53c4031408 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Tue, 24 Jan 2023 09:40:30 +0100 Subject: [PATCH] allow dynamic config file path --- README.md | 2 +- loadtest/config.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f4cf02f..f46fe98 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ To display the profile in a browser, run: ## Configuration -The `loadtest` container reads test parameters from the file `loadtest.yml` the +The `loadtest` container reads test parameters from the file `loadtest.yml` (or the filename specified in the `CONFIG_FILE` environment variable) the following parameters are available: * `paymentAmountMsat`: the test amount that is paid diff --git a/loadtest/config.go b/loadtest/config.go index 7c56900..75fed5b 100644 --- a/loadtest/config.go +++ b/loadtest/config.go @@ -3,6 +3,7 @@ package main import ( "errors" "io/ioutil" + "os" "gopkg.in/yaml.v2" ) @@ -48,7 +49,11 @@ type config struct { } func loadConfig() (*config, error) { - yamlFile, err := ioutil.ReadFile("loadtest.yml") + configFile := os.Getenv("CONFIG_FILE") + if configFile == "" { + configFile = "loadtest.yaml" + } + yamlFile, err := ioutil.ReadFile(configFile) if err != nil { return nil, err }