2020-08-09 17:04:05 +00:00
|
|
|
/*
|
|
|
|
Copyright 2020 VMware, Inc.
|
|
|
|
SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
|
2020-08-28 15:59:09 +00:00
|
|
|
"github.com/suzerain-io/pinniped/internal/controllerlib"
|
2020-08-09 17:04:05 +00:00
|
|
|
)
|
|
|
|
|
2020-08-28 15:59:09 +00:00
|
|
|
func NameAndNamespaceExactMatchFilterFactory(name, namespace string) controllerlib.FilterFuncs {
|
2020-08-09 17:04:05 +00:00
|
|
|
objMatchesFunc := func(obj metav1.Object) bool {
|
|
|
|
return obj.GetName() == name && obj.GetNamespace() == namespace
|
|
|
|
}
|
2020-08-28 15:59:09 +00:00
|
|
|
return controllerlib.FilterFuncs{
|
2020-08-09 17:04:05 +00:00
|
|
|
AddFunc: objMatchesFunc,
|
|
|
|
UpdateFunc: func(oldObj, newObj metav1.Object) bool {
|
|
|
|
return objMatchesFunc(oldObj) || objMatchesFunc(newObj)
|
|
|
|
},
|
|
|
|
DeleteFunc: objMatchesFunc,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 15:59:09 +00:00
|
|
|
// Same signature as controllerlib.WithInformer().
|
2020-08-09 17:04:05 +00:00
|
|
|
type WithInformerOptionFunc func(
|
2020-08-28 15:59:09 +00:00
|
|
|
getter controllerlib.InformerGetter,
|
|
|
|
filter controllerlib.Filter,
|
|
|
|
opt controllerlib.InformerOption) controllerlib.Option
|
2020-08-11 17:14:57 +00:00
|
|
|
|
2020-08-28 15:59:09 +00:00
|
|
|
// Same signature as controllerlib.WithInitialEvent().
|
|
|
|
type WithInitialEventOptionFunc func(key controllerlib.Key) controllerlib.Option
|