Torben Nehmer
7dd11a0879
- NFT and DNS Update skeletons - Integrated viper configuration management - Integrated cobra CLI management - Basic webservice skeleton
31 lines
636 B
Go
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()
|
|
}
|