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.SetEnvPrefix("LUME_WEB_PORTAL")
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
|
defaults()
|
||||||
|
|
||||||
err := viper.ReadInConfig()
|
err := viper.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.As(err, &viper.ConfigFileNotFoundError{}) {
|
if errors.As(err, &viper.ConfigFileNotFoundError{}) {
|
||||||
logger.Info("Config file not found, using default settings.")
|
logger.Info("Config file not found, using default settings.")
|
||||||
|
err := viper.SafeWriteConfig()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -36,3 +42,7 @@ func Init(logger *zap.Logger) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaults() {
|
||||||
|
viper.SetDefault("core.post-upload-limit", 1024*1024*1000)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue