Make sqlboiler respect environment
- Stop failing on config file load, use the validation in the test config stuff.
This commit is contained in:
parent
1839b9fa03
commit
ac549c9207
3 changed files with 11 additions and 9 deletions
4
main.go
4
main.go
|
@ -64,8 +64,10 @@ func main() {
|
|||
rootCmd.PersistentFlags().StringP("output", "o", "models", "The name of the folder to output to")
|
||||
rootCmd.PersistentFlags().StringP("pkgname", "p", "models", "The name you wish to assign to your generated package")
|
||||
|
||||
viper.SetDefault("postgres.sslmode", "required")
|
||||
viper.SetDefault("postgres.sslmode", "require")
|
||||
viper.SetDefault("postgres.port", "5432")
|
||||
viper.BindPFlags(rootCmd.PersistentFlags())
|
||||
viper.AutomaticEnv()
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
if e, ok := err.(commandFailure); ok {
|
||||
|
|
|
@ -115,7 +115,8 @@ func setup() error {
|
|||
return fmt.Errorf("Unable to load config file: %s", err)
|
||||
}
|
||||
|
||||
viper.SetDefault("postgres.sslmode", "required")
|
||||
viper.SetDefault("postgres.sslmode", "require")
|
||||
viper.SetDefault("postgres.port", "5432")
|
||||
|
||||
// Create a randomized test configuration object.
|
||||
testCfg.Postgres.Host = viper.GetString("postgres.host")
|
||||
|
|
|
@ -29,10 +29,9 @@ func InitViper() error {
|
|||
viper.AddConfigPath(p)
|
||||
}
|
||||
|
||||
err = viper.ReadInConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Ignore errors here, fall back to defaults and validation to provide errs
|
||||
_ = viper.ReadInConfig()
|
||||
viper.AutomaticEnv()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue