in cli/azd/pkg/apphost/aca_ingress.go [226:302]
func pickIngress(endpointByTargetPortProperties map[string]*acaPort, httpIngress string, defaultPort int) (
*genContainerAppIngress, []string, error) {
finalIngress := &genContainerAppIngress{}
var bindingNamesFromIngress []string
ingress := httpIngress
if ingress != "" {
props := endpointByTargetPortProperties[ingress]
for _, binding := range props.bindings {
if props.httpOnly && binding.Port != nil && binding.Scheme == acaIngressSchemaHttp && *binding.Port != 80 {
// Main ingress http with non default port rule
return nil, nil,
fmt.Errorf(
"Binding %s can't be mapped to main ingress because it has port %d defined. "+
"main ingress only supports port 80 for http scheme.",
binding.name, *binding.Port)
}
if props.httpOnly && binding.Port != nil && binding.Scheme == acaIngressSchemaHttps && *binding.Port != 443 {
// Main ingress https with non default port rule
return nil, nil,
fmt.Errorf(
"Binding %s can't be mapped to main ingress because it has port %d defined. "+
"main ingress only supports port 443 for https scheme.",
binding.name, *binding.Port)
}
bindingNamesFromIngress = append(bindingNamesFromIngress, binding.name)
}
finalIngress.External = props.external
finalIngress.TargetPort = props.port
if finalIngress.TargetPort == 0 {
finalIngress.TargetPort = defaultPort
finalIngress.UsingDefaultPort = true
}
finalIngress.Transport = acaIngressSchemaHttp
if props.hasHttp2 {
finalIngress.Transport = acaIngressTransportHttp2
}
if props.hasHttp2 || !props.external {
finalIngress.AllowInsecure = true
}
} else {
// ingress still empty b/c no http ingress. pick the first group with lowest index
minIndex := 0
for groupKey, group := range endpointByTargetPortProperties {
for _, binding := range group.bindings {
if ingress == "" || binding.order < minIndex {
minIndex = binding.order
ingress = groupKey
}
}
}
selectedIngress := endpointByTargetPortProperties[ingress]
for _, binding := range selectedIngress.bindings {
bindingNamesFromIngress = append(bindingNamesFromIngress, binding.name)
}
port := selectedIngress.port
finalIngress.Transport = acaIngressSchemaTcp
finalIngress.TargetPort = port
finalIngress.ExposedPort = selectedIngress.exposedPort
}
for groupKey, props := range endpointByTargetPortProperties {
if groupKey == ingress {
continue
}
finalIngress.AdditionalPortMappings = append(finalIngress.AdditionalPortMappings,
genContainerAppIngressAdditionalPortMappings{
genContainerAppIngressPort: genContainerAppIngressPort{
TargetPort: props.port,
ExposedPort: props.exposedPort,
},
})
}
return finalIngress, bindingNamesFromIngress, nil
}