dyndns/cmd/config.go
Torben Nehmer 7dd11a0879 First basic version
- NFT and DNS Update skeletons
- Integrated viper configuration management
- Integrated cobra CLI management
- Basic webservice skeleton
2021-08-20 21:10:59 +02:00

31 lines
636 B
Go

package cmd
import (
"fmt"
"log"
"gitea.nehmer.net/torben/dyndns/service"
"gitea.nehmer.net/torben/dyndns/webapi"
"github.com/spf13/viper"
)
func InitializeViper() {
viper.SetConfigName("conf.yml")
viper.SetConfigType("yaml")
viper.AddConfigPath("/etc/dyndns")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
log.Println("Could not find configfile, using defaults")
} else {
log.Fatalln(fmt.Sprintf("configuration is invalid: %s", err))
}
}
}
func setAllConfigDefaults() {
service.SetConfigDefaults()
webapi.SetConfigDefaults()
}