Skip to content

Commit

Permalink
fix(authz): middleware didn't initialize an in-cluster client
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan-pad committed Apr 26, 2024
1 parent 4e11e3d commit aa81769
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/utils/authz/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
v1 "k8s.io/api/authentication/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
client "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)

type (
Expand All @@ -23,8 +24,17 @@ type (
)

func NewAuthz() *Authz {
config, err := rest.InClusterConfig()
if err != nil {
panic(err.Error())
}
clientset, err := client.NewForConfig(config)
if err != nil {
panic(err.Error())
}
return &Authz{
Cache: cache.New(5*time.Minute, 10*time.Minute),
Cache: cache.New(5*time.Minute, 10*time.Minute),
Client: *clientset,
}
}

Expand Down

0 comments on commit aa81769

Please sign in to comment.