Ajouter api.NewApiClientFromViper() et flags manquants associés #70

Merged
vlbeaudoin merged 2 commits from feature/new-from-viper into main 2023-07-14 20:17:25 -04:00
2 changed files with 17 additions and 2 deletions
Showing only changes of commit 04de5cdad2 - Show all commits

View file

@ -110,6 +110,18 @@ func init() {
serverCmd.Flags().String("server-api-key", "agecem-org", "Key to use for authenticating to /v1 routes") serverCmd.Flags().String("server-api-key", "agecem-org", "Key to use for authenticating to /v1 routes")
viper.BindPFlag("server.api.key", serverCmd.Flags().Lookup("server-api-key")) viper.BindPFlag("server.api.key", serverCmd.Flags().Lookup("server-api-key"))
// server.api.port
serverCmd.Flags().Int("server-api-port", 8080, "API server port (config: server.api.port)")
viper.BindPFlag("server.api.port", serverCmd.Flags().Lookup("server-api-port"))
// server.api.protocol
serverCmd.Flags().String("server-api-protocol", "http", "API server protocol (http/https) (config: server.api.protocol)")
viper.BindPFlag("server.api.protocol", serverCmd.Flags().Lookup("server-api-protocol"))
// server.api.host
serverCmd.Flags().String("server-api-host", "localhost", "API server host (config: server.api.host)")
viper.BindPFlag("server.api.host", serverCmd.Flags().Lookup("server-api-host"))
// server.admin.auth - --server-admin-auth // server.admin.auth - --server-admin-auth
serverCmd.Flags().Bool("server-admin-auth", true, "Enable to allow basic authentication for /admin routes (config: server.admin.auth)") serverCmd.Flags().Bool("server-admin-auth", true, "Enable to allow basic authentication for /admin routes (config: server.admin.auth)")
viper.BindPFlag("server.admin.auth", serverCmd.Flags().Lookup("server-admin-auth")) viper.BindPFlag("server.admin.auth", serverCmd.Flags().Lookup("server-admin-auth"))

View file

@ -22,7 +22,10 @@ type Config struct {
} `mapstructure:"admin"` } `mapstructure:"admin"`
Api struct { Api struct {
Auth bool `mapstructure:"auth"` Auth bool `mapstructure:"auth"`
Host string `mapstructure:"host"`
Key string `mapstructure:"key"` Key string `mapstructure:"key"`
Port int `mapstructure:"port"`
Protocol string `mapstructure:"protocol"`
} `mapstructure:"api"` } `mapstructure:"api"`
Documents struct { Documents struct {
AccessKeyId string `mapstructure:"access_key_id"` AccessKeyId string `mapstructure:"access_key_id"`