Skip to content

Commit c68e954

Browse files
Changed to a switch statment on tls.Termination in validator
1 parent 1020413 commit c68e954

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/route/api/validation/validation.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,17 @@ func validateInsecureEdgeTerminationPolicy(tls *routeapi.TLSConfig, fldPath *fie
272272
routeapi.InsecureEdgeTerminationPolicyRedirect: {},
273273
}
274274

275-
if routeapi.TLSTerminationEdge == tls.Termination || routeapi.TLSTerminationReencrypt == tls.Termination {
275+
switch tls.Termination {
276+
case routeapi.TLSTerminationReencrypt:
277+
fallthrough
278+
case routeapi.TLSTerminationEdge:
276279
if _, ok := allowedValues[tls.InsecureEdgeTerminationPolicy]; !ok {
277280
msg := fmt.Sprintf("invalid value for InsecureEdgeTerminationPolicy option, acceptable values are %s, %s, %s, or empty", routeapi.InsecureEdgeTerminationPolicyNone, routeapi.InsecureEdgeTerminationPolicyAllow, routeapi.InsecureEdgeTerminationPolicyRedirect)
278281
return field.Invalid(fldPath, tls.InsecureEdgeTerminationPolicy, msg)
279282
}
280-
} else if routeapi.TLSTerminationPassthrough == tls.Termination {
283+
case routeapi.TLSTerminationPassthrough:
281284
if routeapi.InsecureEdgeTerminationPolicyNone != tls.InsecureEdgeTerminationPolicy && routeapi.InsecureEdgeTerminationPolicyRedirect != tls.InsecureEdgeTerminationPolicy {
282-
msg := fmt.Sprintf("invalid value for InsecureEdgeTerminationPolicy option acceptable values are %s, %s, or empty", routeapi.InsecureEdgeTerminationPolicyNone, routeapi.InsecureEdgeTerminationPolicyRedirect)
285+
msg := fmt.Sprintf("invalid value for InsecureEdgeTerminationPolicy option, acceptable values are %s, %s, or empty", routeapi.InsecureEdgeTerminationPolicyNone, routeapi.InsecureEdgeTerminationPolicyRedirect)
283286
return field.Invalid(fldPath, tls.InsecureEdgeTerminationPolicy, msg)
284287
}
285288
}

0 commit comments

Comments
 (0)