forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper.go
41 lines (33 loc) · 1.1 KB
/
helper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package api
import (
"strings"
kapi "k8s.io/kubernetes/pkg/api"
)
// IngressConditionStatus returns the first status and condition matching the provided ingress condition type. Conditions
// prefer the first matching entry and clients are allowed to ignore later conditions of the same type.
func IngressConditionStatus(ingress *RouteIngress, t RouteIngressConditionType) (kapi.ConditionStatus, RouteIngressCondition) {
for _, condition := range ingress.Conditions {
if t != condition.Type {
continue
}
return condition.Status, condition
}
return kapi.ConditionUnknown, RouteIngressCondition{}
}
func RouteLessThan(route1, route2 *Route) bool {
if route1.CreationTimestamp.Before(route2.CreationTimestamp) {
return true
}
if route2.CreationTimestamp.Before(route1.CreationTimestamp) {
return false
}
return route1.UID < route2.UID
}
// GetDomainForHost returns the domain for the specified host.
// Note for top level domains, this will return an empty string.
func GetDomainForHost(host string) string {
if idx := strings.IndexRune(host, '.'); idx > -1 {
return host[idx+1:]
}
return ""
}