From f7ba92a94e8c731955b5e5401fab20464e188e6c Mon Sep 17 00:00:00 2001 From: Stavros Kois Date: Tue, 24 Jun 2025 19:11:01 +0300 Subject: [PATCH] don't crash if config file is missing --- hscontrol/types/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hscontrol/types/config.go b/hscontrol/types/config.go index 09e6f818..baf8f264 100644 --- a/hscontrol/types/config.go +++ b/hscontrol/types/config.go @@ -335,6 +335,10 @@ func LoadConfig(path string, isFile bool) error { viper.SetDefault("prefixes.allocation", string(IPAllocationStrategySequential)) if err := viper.ReadInConfig(); err != nil { + if errors.Is(err, fs.ErrNotExist) { + log.Warn().Msg("No config file found, using defaults") + return nil + } return fmt.Errorf("fatal error reading config file: %w", err) }