Skip to content

Commit

Permalink
Merge branch 'main' into fix/oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
jjngx authored May 9, 2023
2 parents 0a7c9bc + 18a37de commit 22e2007
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions pkg/apis/configuration/validation/transportserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,13 @@ func validateListenerName(name string, fieldPath *field.Path) field.ErrorList {
return validateDNS1035Label(name, fieldPath)
}

// listenerProtocols defines the protocols supported by a listener.
var listenerProtocols = map[string]bool{
"TCP": true,
"UDP": true,
}

func validateListenerProtocol(protocol string, fieldPath *field.Path) field.ErrorList {
if protocol == "" {
msg := fmt.Sprintf("must specify protocol. Accepted values: %s", mapToPrettyString(listenerProtocols))
return field.ErrorList{field.Required(fieldPath, msg)}
}
if !listenerProtocols[protocol] {
msg := fmt.Sprintf("invalid protocol. Accepted values: %s", mapToPrettyString(listenerProtocols))
return field.ErrorList{field.Invalid(fieldPath, protocol, msg)}
switch protocol {
case "TCP", "UDP":
return nil
default:
return field.ErrorList{field.Invalid(fieldPath, protocol, "must specify protocol. Accepted values: TCP, UDP.")}
}
return nil
}

func validateTransportServerUpstreams(upstreams []v1alpha1.Upstream, fieldPath *field.Path, isPlus bool) (allErrs field.ErrorList, upstreamNames sets.Set[string]) {
Expand Down

0 comments on commit 22e2007

Please sign in to comment.