-
Notifications
You must be signed in to change notification settings - Fork 228
/
predicates.go
38 lines (35 loc) · 1023 Bytes
/
predicates.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
package infrastructureconfig
import (
configv1 "github.com/openshift/api/config/v1"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)
// onPremPlatformPredicate implements a create and update predicate function on on-prem platform changes
func onPremPlatformPredicate() predicate.Predicate {
return predicate.Funcs{
CreateFunc: func(e event.CreateEvent) bool {
infra := e.Object.(*configv1.Infrastructure)
return isOnPremPlatform(infra)
},
UpdateFunc: func(e event.UpdateEvent) bool {
infra := e.ObjectNew.(*configv1.Infrastructure)
return isOnPremPlatform(infra)
},
}
}
func isOnPremPlatform(infra *configv1.Infrastructure) bool {
switch infra.Spec.PlatformSpec.Type {
case configv1.BareMetalPlatformType:
fallthrough
case configv1.VSpherePlatformType:
fallthrough
case configv1.OpenStackPlatformType:
fallthrough
case configv1.OvirtPlatformType:
fallthrough
case configv1.NutanixPlatformType:
return true
default:
return false
}
}