certwarden-deploy/internal/configuration/config.go
2024-07-03 10:00:21 +02:00

27 lines
518 B
Go

package configuration
import (
"fmt"
"os"
"gopkg.in/yaml.v3"
)
func InitializeConfig() (*ConfigFileData, error) {
var cfg ConfigFileData
if ConfigFile == "" {
ConfigFile = "/etc/certwarden-deploy/config.yaml"
}
data, err := os.ReadFile(ConfigFile)
if err != nil {
return &ConfigFileData{}, fmt.Errorf("failed to read config file: %w", err)
}
err = yaml.Unmarshal(data, &cfg)
if err != nil {
return &ConfigFileData{}, fmt.Errorf("failed to unmarshal config file: %w", err)
}
return &cfg, nil
}