Skip to content

Commit 1fdc23a

Browse files
committed
Update code to use hashicorp/golang-lru/v2
1 parent 774e632 commit 1fdc23a

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require (
66
github.com/AlekSi/pointer v1.2.0
77
github.com/getkin/kin-openapi v0.133.0
88
github.com/go-logr/logr v1.4.3
9-
github.com/hashicorp/golang-lru v1.0.2
109
github.com/hashicorp/golang-lru/v2 v2.0.7
1110
github.com/labstack/echo/v4 v4.15.1
1211
github.com/oapi-codegen/echo-middleware v1.0.2

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
155155
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
156156
github.com/hairyhenderson/go-codeowners v0.7.0 h1:s0W4wF8bdsBEjTWzwzSlsatSthWtTAF2xLgo4a4RwAo=
157157
github.com/hairyhenderson/go-codeowners v0.7.0/go.mod h1:wUlNgQ3QjqC4z8DnM5nnCYVq/icpqXJyJOukKx5U8/Q=
158-
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
159-
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
160158
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
161159
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
162160
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=

pkg/service/kubernetes_auth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77
"strings"
88

9-
lruCache "github.com/hashicorp/golang-lru"
9+
lruCache "github.com/hashicorp/golang-lru/v2"
1010
"github.com/labstack/echo/v4"
1111
"k8s.io/apimachinery/pkg/util/runtime"
1212
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -42,16 +42,16 @@ func getCacheSizeOrDefault(def int) int {
4242
return parsed
4343
}
4444

45-
func createCache() *lruCache.Cache {
46-
cache, err := lruCache.NewWithEvict(getCacheSizeOrDefault(128), nil)
45+
func createCache() *lruCache.Cache[string, client.Client] {
46+
cache, err := lruCache.NewWithEvict[string, client.Client](getCacheSizeOrDefault(128), nil)
4747
runtime.Must(err)
4848
return cache
4949
}
5050

5151
// KubernetesAuth provides middleware to authenticate with Kubernetes JWT tokens
5252
type KubernetesAuth struct {
5353
CreateClientFunc func(string) (client.Client, error)
54-
cache *lruCache.Cache
54+
cache *lruCache.Cache[string, client.Client]
5555
}
5656

5757
// DefaultKubernetesAuth uses the JWT bearer token to authenticate

0 commit comments

Comments
 (0)