feat: handle missing config file gracefully with a warning (#331)

Signed-off-by: Dmytro Bondar <git@bonddim.com>
This commit is contained in:
Dmytro Bondar 2024-12-10 15:17:31 +01:00 committed by GitHub
parent 983568b36a
commit 0ea24e313d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -159,6 +159,10 @@ func GetConfig() (*Config, error) {
func loadConfigFile(cfg any, filename string) error { func loadConfigFile(cfg any, filename string) error {
data, err := envsubst.ReadFile(filename) data, err := envsubst.ReadFile(filename)
if err != nil { if err != nil {
if os.IsNotExist(err) {
logrus.Warnf("Config file %s not found, using default values", filename)
return nil
}
return fmt.Errorf("envsubst error: %v", err) return fmt.Errorf("envsubst error: %v", err)
} }