Merge branch 'feature/bottin-flags' into main

This commit is contained in:
Victor Lacasse-Beaudoin 2023-09-16 18:23:16 -04:00
commit 4bbc91878f
2 changed files with 23 additions and 2 deletions

View file

@ -32,7 +32,7 @@ var apiCmd = &cobra.Command{
v0 := e.Group("/v0")
bottinApiClient := bottindata.NewApiClient("bottin", "localhost", "http", 1312)
bottinApiClient := bottindata.NewApiClient(cfg.Bottin.API.Key, cfg.Bottin.API.Host, cfg.Bottin.API.Protocol, cfg.Bottin.API.Port)
dbClient, err := dbclient.New("db", "bottinag", "bottinag", "bottinag", 5432, false)
if err != nil {

View file

@ -21,7 +21,10 @@ type APIConfig struct {
type BottinConfig struct {
API struct {
Host string
Host string
Key string
Port int
Protocol string
}
}
@ -69,6 +72,24 @@ func RegisterFlags(cmd *cobra.Command) error {
return err
}
// bottin.api.key
if err := RegisterString(cmd, true,
"bottin.api.key", "bottin-api-key", "Bottin API server key", "bottin"); err != nil {
return err
}
// bottin.api.port
if err := RegisterInt(cmd, true,
"bottin.api.port", "bottin-api-port", "Bottin API server port", 1312); err != nil {
return err
}
// bottin.api.protocol
if err := RegisterString(cmd, true,
"bottin.api.protocol", "bottin-api-protocol", "Bottin API server protocol", "http"); err != nil {
return err
}
// web.port ; --web-port
cmd.PersistentFlags().Int("web-port", 3183, "Webserver port")
if err := viper.BindPFlag("web.port", cmd.PersistentFlags().Lookup("web-port")); err != nil {