From f6a81658d344b03e55d28d19a66d3a67703549e9 Mon Sep 17 00:00:00 2001 From: Pierre-yves FONTANIERE Date: Mon, 16 Sep 2024 16:25:37 +0200 Subject: [PATCH] Add function to create configuration from fullpath defined file --- ov/config.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ov/config.go b/ov/config.go index 1fa66660..21af0772 100644 --- a/ov/config.go +++ b/ov/config.go @@ -93,10 +93,9 @@ type ServerProfileConfig struct { OvTemplatestring string `json:"ov_template"` } -func LoadConfigFile(configFile string) (Configuration, error) { - _, filename, _, _ := runtime.Caller(1) - configFilePath := filepath.Join(filepath.Dir(filename), configFile) +func LoadConfigFilePath(configFilePath string) (Configuration, error) { configF, err := os.Open(configFilePath) + var config Configuration defer configF.Close() if err != nil { @@ -114,4 +113,12 @@ func LoadConfigFile(configFile string) (Configuration, error) { } return config, nil + +} + +func LoadConfigFile(configFile string) (Configuration, error) { + _, filename, _, _ := runtime.Caller(1) + configFilePath := filepath.Join(filepath.Dir(filename), configFile) + + return LoadConfigFilePath(configFilePath) }