mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
e267a1dacf
* fix: harden certs secrets management Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * rbac Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * informers Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package informers
|
|
|
|
import (
|
|
"time"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/fields"
|
|
corev1informers "k8s.io/client-go/informers/core/v1"
|
|
"k8s.io/client-go/kubernetes"
|
|
corev1listers "k8s.io/client-go/listers/core/v1"
|
|
"k8s.io/client-go/tools/cache"
|
|
)
|
|
|
|
type secretInformer struct {
|
|
informer cache.SharedIndexInformer
|
|
lister corev1listers.SecretLister
|
|
}
|
|
|
|
func NewSecretInformer(
|
|
client kubernetes.Interface,
|
|
namespace string,
|
|
name string,
|
|
resyncPeriod time.Duration,
|
|
) corev1informers.SecretInformer {
|
|
indexers := cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}
|
|
options := func(lo *metav1.ListOptions) {
|
|
lo.FieldSelector = fields.OneTermEqualSelector(metav1.ObjectNameField, name).String()
|
|
}
|
|
informer := corev1informers.NewFilteredSecretInformer(
|
|
client,
|
|
namespace,
|
|
resyncPeriod,
|
|
indexers,
|
|
options,
|
|
)
|
|
lister := corev1listers.NewSecretLister(informer.GetIndexer())
|
|
return &secretInformer{informer, lister}
|
|
}
|
|
|
|
func (i *secretInformer) Informer() cache.SharedIndexInformer {
|
|
return i.informer
|
|
}
|
|
|
|
func (i *secretInformer) Lister() corev1listers.SecretLister {
|
|
return i.lister
|
|
}
|