-
Notifications
You must be signed in to change notification settings - Fork 95
/
route.go
42 lines (37 loc) · 1.04 KB
/
route.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
42
package helper
import (
routev1 "github.com/openshift/api/route/v1"
v1 "k8s.io/api/core/v1"
)
// IsRouteReady returns true when all Ingresses of the Route have the
// "Admitted" Condition set to true
func IsRouteReady(route *routev1.Route) bool {
routeStatusIngresses := route.Status.Ingress
if len(routeStatusIngresses) == 0 {
return false
}
for _, routeStatusIngress := range routeStatusIngresses {
routeStatusIngressConditions := routeStatusIngress.Conditions
isReady := false
for _, routeStatusIngressCondition := range routeStatusIngressConditions {
if routeStatusIngressCondition.Type == routev1.RouteAdmitted && routeStatusIngressCondition.Status == v1.ConditionTrue {
isReady = true
break
}
}
if !isReady {
return false
}
}
return true
}
// RouteFindByHost returns the smallest index i at which a route with a given host is found
// or -1 if there is no such index.
func RouteFindByHost(a []routev1.Route, routeHost string) int {
for i, n := range a {
if n.Spec.Host == routeHost {
return i
}
}
return -1
}