in pkg/controller/nginxingress/index.go [63:99]
func IngressSource(ctx context.Context, cl client.Client, conf *config.Config, defaultControllerClass string, ing *netv1.Ingress, ingressClassNameIndex string) (policyv1alpha1.IngressSourceSpec, bool, error) {
ic := ing.Spec.IngressClassName
if ic == nil {
return policyv1alpha1.IngressSourceSpec{}, false, nil
}
// if it's the default one we should assume we own it because there's time in the upgrade from non crd app routing to crd app routing where a crd for the default doesn't exist
if *ic == DefaultIcName {
return policyv1alpha1.IngressSourceSpec{
Kind: "Service",
Name: DefaultNicResourceName,
Namespace: conf.NS,
}, true, nil
}
nics := &approutingv1alpha1.NginxIngressControllerList{}
err := cl.List(ctx, nics, client.MatchingFields{ingressClassNameIndex: *ic})
if err == nil {
if len(nics.Items) == 0 {
return policyv1alpha1.IngressSourceSpec{}, false, nil
}
nic := nics.Items[0]
ingressConfig := ToNginxIngressConfig(&nic, defaultControllerClass)
return policyv1alpha1.IngressSourceSpec{
Kind: "Service",
Name: ingressConfig.ResourceName,
Namespace: conf.NS,
}, true, nil
}
if !k8serrors.IsNotFound(err) {
return policyv1alpha1.IngressSourceSpec{}, false, fmt.Errorf("listing nginx ingress controllers: %w", err)
}
return policyv1alpha1.IngressSourceSpec{}, false, nil
}