42 lines
1 KiB
Go
42 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/spf13/pflag"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
const (
|
|
configPort = "Port"
|
|
defaultPort = 8080
|
|
flagPort = "port"
|
|
|
|
configTLSCert = "TLS.Cert"
|
|
defaultTLSCert = ""
|
|
flagTLSCert = "tls-cert"
|
|
|
|
configTLSKey = "TLS.Key"
|
|
defaultTLSKey = ""
|
|
flagTLSKey = "tls-key"
|
|
)
|
|
|
|
// BindClientFlags declares client-related flags and config options in the specified *pflag.FlagSet
|
|
func BindFlags(set *pflag.FlagSet) error {
|
|
// Credentials -> seulement par config
|
|
|
|
set.Int(flagPort, defaultPort, "User interface port")
|
|
if err := viper.BindPFlag(configPort, set.Lookup(flagPort)); err != nil {
|
|
return err
|
|
}
|
|
|
|
set.String(flagTLSKey, defaultTLSKey, "User interface TLS private key (or path to file)")
|
|
if err := viper.BindPFlag(configTLSKey, set.Lookup(flagTLSKey)); err != nil {
|
|
return err
|
|
}
|
|
|
|
set.String(flagTLSCert, defaultTLSCert, "User interface TLS certificate (or path to file)")
|
|
if err := viper.BindPFlag(configTLSCert, set.Lookup(flagTLSCert)); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|