mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-02-14 18:29:52 +00:00
Validate config parameters for random delay
- random-delay-max should not be less than random-delay-min - random-delay-unit accepted values: s|ms
This commit is contained in:
@@ -104,6 +104,20 @@ func main() {
|
||||
viper.Set("port", strconv.Itoa(port))
|
||||
}
|
||||
|
||||
// validate random delay options
|
||||
if viper.GetInt("random-delay-max") < viper.GetInt("random-delay-min") {
|
||||
logger.Panic("`--random-delay-max` should be greater than `--random-delay-min`")
|
||||
}
|
||||
|
||||
switch delayUnit := viper.GetString("random-delay-unit"); delayUnit {
|
||||
case
|
||||
"s",
|
||||
"ms":
|
||||
break
|
||||
default:
|
||||
logger.Panic("`random-delay-unit` accepted values are: s|ms")
|
||||
}
|
||||
|
||||
// load gRPC server config
|
||||
var grpcCfg grpc.Config
|
||||
if err := viper.Unmarshal(&grpcCfg); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user