don't crash if config file is missing (#2656)

This commit is contained in:
Stavros Kois 2025-07-04 15:58:17 +03:00 committed by GitHub
parent 3bad5d5590
commit ded049b905
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -16,6 +16,8 @@
[#2046](https://github.com/juanfont/headscale/pull/2046)
- Refactor OpenID Connect documentation
[#2625](https://github.com/juanfont/headscale/pull/2625)
- Don't crash if config file is missing
[#2656](https://github.com/juanfont/headscale/pull/2656)
## 0.26.1 (2025-06-06)

View File

@ -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)
}