1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/pkg/informers/helpers.go
Charles-Edouard Brétéché e267a1dacf
fix: harden certs secrets management (#7634)
* 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>
2023-06-22 20:14:53 +08:00

33 lines
866 B
Go

package informers
import (
"context"
"github.com/go-logr/logr"
"k8s.io/client-go/tools/cache"
)
type informer interface {
Informer() cache.SharedIndexInformer
}
func StartInformers(ctx context.Context, informers ...informer) {
for i := range informers {
go func(informer cache.SharedIndexInformer) {
informer.Run(ctx.Done())
}(informers[i].Informer())
}
}
func WaitForCacheSync(ctx context.Context, logger logr.Logger, informers ...informer) bool {
var cacheSyncs []cache.InformerSynced
for i := range informers {
cacheSyncs = append(cacheSyncs, informers[i].Informer().HasSynced)
}
return cache.WaitForCacheSync(ctx.Done(), cacheSyncs...)
}
func StartInformersAndWaitForCacheSync(ctx context.Context, logger logr.Logger, informers ...informer) bool {
StartInformers(ctx, informers...)
return WaitForCacheSync(ctx, logger, informers...)
}