refactor: set default options starting with core.post-upload-limi, and save the config when none exists
This commit is contained in:
parent
492bd5b9de
commit
9ebdeb74c6
|
@ -25,10 +25,16 @@ func Init(logger *zap.Logger) error {
|
|||
viper.SetEnvPrefix("LUME_WEB_PORTAL")
|
||||
viper.AutomaticEnv()
|
||||
|
||||
defaults()
|
||||
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
if errors.As(err, &viper.ConfigFileNotFoundError{}) {
|
||||
logger.Info("Config file not found, using default settings.")
|
||||
err := viper.SafeWriteConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
@ -36,3 +42,7 @@ func Init(logger *zap.Logger) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaults() {
|
||||
viper.SetDefault("core.post-upload-limit", 1024*1024*1000)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue