in pkg/appgw/frontend_listeners.go [145:186]
func (c *appGwConfigBuilder) newListener(cbCtx *ConfigBuilderContext, listenerID listenerIdentifier, protocol n.ApplicationGatewayProtocol, portsByNumber map[Port]n.ApplicationGatewayFrontendPort) (*n.ApplicationGatewayHTTPListener, *n.ApplicationGatewayFrontendPort, error) {
frontIPConfiguration := *LookupIPConfigurationByType(c.appGw.FrontendIPConfigurations, listenerID.FrontendType)
portNumber := listenerID.FrontendPort
var frontendPort n.ApplicationGatewayFrontendPort
var exists bool
if frontendPort, exists = portsByNumber[portNumber]; !exists {
portName := generateFrontendPortName(listenerID.FrontendPort)
frontendPort = n.ApplicationGatewayFrontendPort{
Etag: to.StringPtr("*"),
Name: &portName,
ID: to.StringPtr(c.appGwIdentifier.frontendPortID(portName)),
ApplicationGatewayFrontendPortPropertiesFormat: &n.ApplicationGatewayFrontendPortPropertiesFormat{
Port: to.Int32Ptr(int32(portNumber)),
},
}
}
listenerName := generateListenerName(listenerID)
listener := n.ApplicationGatewayHTTPListener{
Etag: to.StringPtr("*"),
Name: to.StringPtr(listenerName),
ID: to.StringPtr(c.appGwIdentifier.listenerID(listenerName)),
ApplicationGatewayHTTPListenerPropertiesFormat: &n.ApplicationGatewayHTTPListenerPropertiesFormat{
// TODO: expose this to external configuration
FrontendIPConfiguration: resourceRef(*frontIPConfiguration.ID),
FrontendPort: resourceRef(*frontendPort.ID),
Protocol: protocol,
HostName: nil,
HostNames: &[]string{},
// setting to default
RequireServerNameIndication: to.BoolPtr(false),
},
}
// Use only the 'HostNames' field as application gateway allows either 'HostName' or 'HostNames'
if hostNames := listenerID.getHostNames(); len(hostNames) != 0 {
listener.HostNames = &hostNames
}
return &listener, &frontendPort, nil
}