Migrer déclaration de flags à serpents
This commit is contained in:
parent
6d2062aecc
commit
5f9564d93c
4 changed files with 85 additions and 82 deletions
40
cmd/api.go
40
cmd/api.go
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"codeberg.org/vlbeaudoin/serpents"
|
||||
"git.agecem.com/agecem/bottin/v5/data"
|
||||
"git.agecem.com/agecem/bottin/v5/handlers"
|
||||
"github.com/labstack/echo/v4"
|
||||
|
@ -85,34 +86,37 @@ func init() {
|
|||
rootCmd.AddCommand(apiCmd)
|
||||
|
||||
// api.key
|
||||
apiCmd.Flags().String(
|
||||
"api-key", "bottin",
|
||||
"API server key. Leave empty for no key auth. (config: 'api.key')")
|
||||
viper.BindPFlag("api.key", apiCmd.Flags().Lookup("api-key"))
|
||||
serpents.String(apiCmd.Flags(),
|
||||
"api.key", "api-key", "bottin",
|
||||
"API server key. Leave empty for no key auth")
|
||||
|
||||
// api.port
|
||||
apiCmd.Flags().Int(
|
||||
"api-port", 1312,
|
||||
"API server port (config:'api.port')")
|
||||
viper.BindPFlag("api.port", apiCmd.Flags().Lookup("api-port"))
|
||||
serpents.Int(apiCmd.Flags(),
|
||||
"api.port", "api-port", 1312,
|
||||
"API server port")
|
||||
|
||||
// db.database
|
||||
apiCmd.Flags().String("db-database", "bottin", "Postgres database (config:'db.database')")
|
||||
viper.BindPFlag("db.database", apiCmd.Flags().Lookup("db-database"))
|
||||
serpents.String(apiCmd.Flags(),
|
||||
"db.database", "db-database", "bottin",
|
||||
"Postgres database")
|
||||
|
||||
// db.host
|
||||
apiCmd.Flags().String("db-host", "db", "Postgres host (config:'db.host')")
|
||||
viper.BindPFlag("db.host", apiCmd.Flags().Lookup("db-host"))
|
||||
serpents.String(apiCmd.Flags(),
|
||||
"db.host", "db-host", "db",
|
||||
"Postgres host")
|
||||
|
||||
// db.password
|
||||
apiCmd.Flags().String("db-password", "bottin", "Postgres password (config:'db.password')")
|
||||
viper.BindPFlag("db.password", apiCmd.Flags().Lookup("db-password"))
|
||||
serpents.String(apiCmd.Flags(),
|
||||
"db.password", "db-password", "bottin",
|
||||
"Postgres password")
|
||||
|
||||
// db.port
|
||||
apiCmd.Flags().Int("db-port", 5432, "Postgres port (config:'db.port')")
|
||||
viper.BindPFlag("db.port", apiCmd.Flags().Lookup("db-port"))
|
||||
serpents.Int(apiCmd.Flags(),
|
||||
"db.port", "db-port", 5432,
|
||||
"Postgres port")
|
||||
|
||||
// db.user
|
||||
apiCmd.Flags().String("db-user", "bottin", "Postgres user (config:'db.user')")
|
||||
viper.BindPFlag("db.user", apiCmd.Flags().Lookup("db-user"))
|
||||
serpents.String(apiCmd.Flags(),
|
||||
"db.user", "db-user", "bottin",
|
||||
"Postgres user")
|
||||
}
|
||||
|
|
50
cmd/web.go
50
cmd/web.go
|
@ -9,6 +9,7 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/vlbeaudoin/serpents"
|
||||
"git.agecem.com/agecem/bottin/v5/data"
|
||||
"git.agecem.com/agecem/bottin/v5/web"
|
||||
"git.agecem.com/agecem/bottin/v5/web/webhandlers"
|
||||
|
@ -105,44 +106,37 @@ func init() {
|
|||
templatesFS = web.GetTemplates()
|
||||
|
||||
// web.api.host
|
||||
webCmd.Flags().String(
|
||||
"web-api-host", "api",
|
||||
"Remote API server host (config:'web.api.host')")
|
||||
viper.BindPFlag("web.api.host", webCmd.Flags().Lookup("web-api-host"))
|
||||
serpents.String(webCmd.Flags(),
|
||||
"web.api.host", "web-api-host", "api",
|
||||
"Remote API server host")
|
||||
|
||||
// web.api.key
|
||||
webCmd.Flags().String(
|
||||
"web-api-key", "bottin",
|
||||
"Remote API server key (config:'web.api.key')")
|
||||
viper.BindPFlag("web.api.key", webCmd.Flags().Lookup("web-api-key"))
|
||||
serpents.String(webCmd.Flags(),
|
||||
"web.api.key", "web-api-key", "bottin",
|
||||
"Remote API server key")
|
||||
|
||||
// web.api.protocol
|
||||
webCmd.Flags().String(
|
||||
"web-api-protocol", "http",
|
||||
"Remote API server protocol (config:'web.api.protocol')")
|
||||
viper.BindPFlag("web.api.protocol", webCmd.Flags().Lookup("web-api-protocol"))
|
||||
serpents.String(webCmd.Flags(),
|
||||
"web.api.protocol", "web-api-protocol", "http",
|
||||
"Remote API server protocol")
|
||||
|
||||
// web.api.port
|
||||
webCmd.Flags().Int(
|
||||
"web-api-port", 1312,
|
||||
"Remote API server port (config:'web.api.port')")
|
||||
viper.BindPFlag("web.api.port", webCmd.Flags().Lookup("web-api-port"))
|
||||
serpents.Int(webCmd.Flags(),
|
||||
"web.api.port", "web-api-port", 1312,
|
||||
"Remote API server port")
|
||||
|
||||
// web.password
|
||||
webCmd.Flags().String(
|
||||
"web-password", "bottin",
|
||||
"Web client password (config:'web.password')")
|
||||
viper.BindPFlag("web.password", webCmd.Flags().Lookup("web-password"))
|
||||
serpents.String(webCmd.Flags(),
|
||||
"web.password", "web-password", "bottin",
|
||||
"Web client password")
|
||||
|
||||
// web.port
|
||||
webCmd.Flags().Int(
|
||||
"web-port", 2312,
|
||||
"Web client port (config:'web.port')")
|
||||
viper.BindPFlag("web.port", webCmd.Flags().Lookup("web-port"))
|
||||
serpents.Int(webCmd.Flags(),
|
||||
"web.port", "web-port", 2312,
|
||||
"Web client port")
|
||||
|
||||
// web.user
|
||||
webCmd.Flags().String(
|
||||
"web-user", "bottin",
|
||||
"Web client user (config:'web.user')")
|
||||
viper.BindPFlag("web.user", webCmd.Flags().Lookup("web-user"))
|
||||
serpents.String(webCmd.Flags(),
|
||||
"web.user", "web-user", "bottin",
|
||||
"Web client user")
|
||||
}
|
||||
|
|
Reference in a new issue