Skip to content

IngressURL should check annotation first, or at least should not pick url if it contains a wildcard "*" #401

@yelhouti

Description

@yelhouti

func IngressURL(ing *nv1.Ingress) string {
if ing == nil {
log.Logger().Debug("Ingress is nil, returning empty string for url")
return ""
}
if len(ing.Spec.Rules) == 0 {
log.Logger().Debug("Ingress spec has no rules, returning empty string for url")
return ""
}
rule := ing.Spec.Rules[0]
for _, tls := range ing.Spec.TLS {
for _, h := range tls.Hosts {
if h != "" {
url := "https://" + h
log.Logger().Debugf("found service url %s", url)
return url
}
}
}
ann := ing.Annotations
hostname := rule.Host
if hostname == "" && ann != nil {
hostname = ann[kube.AnnotationHost]
}
if hostname == "" {
log.Logger().Debug("Could not find hostname from rule or ingress annotation")
return ""
}
url := "http://" + hostname
if rule.HTTP != nil {
if len(rule.HTTP.Paths) > 0 {
p := rule.HTTP.Paths[0].Path
if p != "" {
url += p
}
}
}
log.Logger().Debugf("found service url %s", url)
return url
}

This doesn't work, when you have wildcard url.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions