in pkg/model/lattice/listener.go [64:83]
func (spec *ListenerSpec) Validate() error {
if _, exists := validListenerProtocols[spec.Protocol]; !exists {
return fmt.Errorf("invalid listener protocol %s", spec.Protocol)
}
if spec.DefaultAction == nil {
return fmt.Errorf("listener default action is required")
}
isFixedResponse := spec.DefaultAction.FixedResponseStatusCode != nil
isForward := spec.DefaultAction.Forward != nil
if isFixedResponse == isForward { // either both true or both false
return fmt.Errorf("invalid listener default action, must be either fixed response or forward")
}
if spec.Protocol != vpclattice.ListenerProtocolTlsPassthrough && !isFixedResponse {
return fmt.Errorf("non TLS_PASSTHROUGH listener default action must be fixed response")
}
if spec.Protocol == vpclattice.ListenerProtocolTlsPassthrough && !isForward {
return fmt.Errorf("TLS_PASSTHROUGH listener default action must be forward")
}
return nil
}