10BC0 Merge branch 'main' into fix/oidc · nginx/kubernetes-ingress@22e2007 · GitHub
[go: up one dir, main page]

Skip to content

Commit 22e2007

Browse files
authored
Merge branch 'main' into fix/oidc
2 parents 0a7c9bc + 18a37de commit 22e2007

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

pkg/apis/configuration/validation/transportserver.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,13 @@ func validateListenerName(name string, fieldPath *field.Path) field.ErrorList {
129129
return validateDNS1035Label(name, fieldPath)
130130
}
131131

132-
// listenerProtocols defines the protocols supported by a listener.
133-
var listenerProtocols = map[string]bool{
134-
"TCP": true,
135-
"UDP": true,
136-
}
137-
138132
func validateListenerProtocol(protocol string, fieldPath *field.Path) field.ErrorList {
139-
if protocol == "" {
140-
msg := fmt.Sprintf("must specify protocol. Accepted values: %s", mapToPrettyString(listenerProtocols))
141-
return field.ErrorList{field.Required(fieldPath, msg)}
142-
}
143-
if !listenerProtocols[protocol] {
144-
msg := fmt.Sprintf("invalid protocol. Accepted values: %s", mapToPrettyString(listenerProtocols))
145-
return field.ErrorList{field.Invalid(fieldPath, protocol, msg)}
133+
switch protocol {
134+
case "TCP", "UDP":
135+
return nil
136+
default:
137+
return field.ErrorList{field.Invalid(fieldPath, protocol, "must specify protocol. Accepted values: TCP, UDP.")}
146138
}
147-
return nil
148139
}
149140

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

0 commit comments

Comments
 (0)
0