in plugins/teststeps/waitport/waitport.go [178:233]
func parseParameters(params test.TestStepParameters) (*parameters, error) {
const maxPortValue = 65535
var target *test.Param
targets := params.Get("target")
switch len(targets) {
case 0:
case 1:
target = &targets[0]
default:
return nil, errors.New("0 or 1 'target' parameters should be provided")
}
port, err := params.GetInt("port")
if err != nil {
return nil, fmt.Errorf("failed to parse 'port' parameter: %w", err)
}
if port <= 0 || port > maxPortValue {
return nil, fmt.Errorf("'port' parameter should be a positive integer that is less than %d, got: '%d'", maxPortValue, port)
}
protocols := params.Get("protocol")
if len(protocols) != 1 {
return nil, errors.New("a single 'protocol' should be provided")
}
protocol := strings.ToLower(protocols[0].String())
isValidProtocol := func() bool {
for _, opt := range protocolOptions {
if opt == protocol {
return true
}
}
return false
}()
if !isValidProtocol {
return nil, fmt.Errorf("'protocol' should be one of [%s]", strings.Join(protocolOptions, ", "))
}
timeout, err := parseDurationParam(params, "timeout")
if err != nil {
return nil, err
}
checkInterval, err := parseDurationParam(params, "check_interval")
if err != nil {
return nil, err
}
return ¶meters{
target: target,
port: int(port),
protocol: protocol,
checkInterval: checkInterval,
timeout: timeout,
}, nil
}