Skip to content

Commit

Permalink
cache client
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly committed Nov 5, 2024
1 parent a57bdf6 commit 2d4850e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/authz/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -23,7 +24,25 @@ func NewGrpcServer(network, addr string, config *rest.Config) server.ServerFunc
return err
}
// create kubernetes client
// TODO: do we want to use a cache ?
cache, err := cache.New(config, cache.Options{
Scheme: scheme,
})
if err != nil {
return err
}
go func() {
if err := cache.Start(ctx); err != nil {
// TODO: better error handling
panic(err)
}
}()
// TODO: use the result of the wait
cache.WaitForCacheSync(ctx)
client, err := client.New(config, client.Options{
Cache: &client.CacheOptions{
Reader: cache,
},
Scheme: scheme,
})
if err != nil {
Expand Down

0 comments on commit 2d4850e

Please sign in to comment.