refactor: move default viper config values to commands/commands.go
This commit is contained in:
parent
86f2d90668
commit
6c7203a4aa
@ -66,6 +66,15 @@ func initConfig() {
|
|||||||
|
|
||||||
// Execute the root cobra command
|
// Execute the root cobra command
|
||||||
func Execute() {
|
func Execute() {
|
||||||
|
viper.SetDefault("server.hostname", "0.0.0.0:3333")
|
||||||
|
viper.SetDefault("database.host", "127.0.0.1")
|
||||||
|
viper.SetDefault("database.name", "taskcafe")
|
||||||
|
viper.SetDefault("database.user", "taskcafe")
|
||||||
|
viper.SetDefault("database.password", "taskcafe_test")
|
||||||
|
|
||||||
|
viper.SetDefault("queue.broker", "amqp://guest:guest@localhost:5672/")
|
||||||
|
viper.SetDefault("queue.store", "memcache://localhost:11211")
|
||||||
|
|
||||||
rootCmd.SetVersionTemplate(versionTemplate)
|
rootCmd.SetVersionTemplate(versionTemplate)
|
||||||
rootCmd.AddCommand(newWebCmd(), newMigrateCmd(), newTokenCmd(), newWorkerCmd(), newResetPasswordCmd())
|
rootCmd.AddCommand(newWebCmd(), newMigrateCmd(), newTokenCmd(), newWorkerCmd(), newResetPasswordCmd())
|
||||||
rootCmd.Execute()
|
rootCmd.Execute()
|
||||||
|
@ -68,9 +68,5 @@ func newMigrateCmd() *cobra.Command {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
viper.SetDefault("database.host", "127.0.0.1")
|
|
||||||
viper.SetDefault("database.name", "taskcafe")
|
|
||||||
viper.SetDefault("database.user", "taskcafe")
|
|
||||||
viper.SetDefault("database.password", "taskcafe_test")
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,6 @@ func newWebCmd() *cobra.Command {
|
|||||||
cc.Flags().Bool("migrate", false, "if true, auto run's schema migrations before starting the web server")
|
cc.Flags().Bool("migrate", false, "if true, auto run's schema migrations before starting the web server")
|
||||||
viper.BindPFlag("migrate", cc.Flags().Lookup("migrate"))
|
viper.BindPFlag("migrate", cc.Flags().Lookup("migrate"))
|
||||||
viper.SetDefault("migrate", false)
|
viper.SetDefault("migrate", false)
|
||||||
viper.SetDefault("server.hostname", "0.0.0.0:3333")
|
|
||||||
viper.SetDefault("database.host", "127.0.0.1")
|
|
||||||
viper.SetDefault("database.name", "taskcafe")
|
|
||||||
viper.SetDefault("database.user", "taskcafe")
|
|
||||||
viper.SetDefault("database.password", "taskcafe_test")
|
|
||||||
|
|
||||||
viper.SetDefault("queue.broker", "amqp://guest:guest@localhost:5672/")
|
|
||||||
viper.SetDefault("queue.store", "memcache://localhost:11211")
|
|
||||||
return cc
|
return cc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +73,5 @@ func newWorkerCmd() *cobra.Command {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
viper.SetDefault("database.host", "127.0.0.1")
|
|
||||||
viper.SetDefault("database.name", "taskcafe")
|
|
||||||
viper.SetDefault("database.user", "taskcafe")
|
|
||||||
viper.SetDefault("database.password", "taskcafe_test")
|
|
||||||
|
|
||||||
viper.SetDefault("queue.broker", "amqp://guest:guest@localhost:5672/")
|
|
||||||
viper.SetDefault("queue.store", "memcache://localhost:11211")
|
|
||||||
return cc
|
return cc
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user