chore: upgrade go dependencies (#3657)

This commit is contained in:
Kevin Wan
2023-10-28 00:19:22 +08:00
committed by GitHub
parent 9394e59597
commit a1fca3a1da
8 changed files with 126 additions and 503 deletions

View File

@@ -1,9 +0,0 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: endpoints-reader
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "watch", "list"]

View File

@@ -1,12 +0,0 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: endpoints-reader
subjects:
- kind: ServiceAccount
name: endpoints-reader
namespace: kevin # the namespace that the ServiceAccount resides in
roleRef:
kind: ClusterRole
name: endpoints-reader
apiGroup: rbac.authorization.k8s.io

View File

@@ -1,5 +0,0 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: endpoints-reader
namespace: kevin # the namespace to create the ServiceAccount

View File

@@ -6,8 +6,11 @@ import (
"github.com/zeromicro/go-zero/core/lang"
"github.com/zeromicro/go-zero/core/logx"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/cache"
)
var _ cache.ResourceEventHandler = (*EventHandler)(nil)
// EventHandler is ResourceEventHandler implementation.
type EventHandler struct {
update func([]string)
@@ -24,7 +27,7 @@ func NewEventHandler(update func([]string)) *EventHandler {
}
// OnAdd handles the endpoints add events.
func (h *EventHandler) OnAdd(obj any) {
func (h *EventHandler) OnAdd(obj any, _ bool) {
endpoints, ok := obj.(*v1.Endpoints)
if !ok {
logx.Errorf("%v is not an object with type *v1.Endpoints", obj)

View File

@@ -13,7 +13,7 @@ func TestAdd(t *testing.T) {
h := NewEventHandler(func(change []string) {
endpoints = change
})
h.OnAdd("bad")
h.OnAdd("bad", false)
h.OnAdd(&v1.Endpoints{Subsets: []v1.EndpointSubset{
{
Addresses: []v1.EndpointAddress{
@@ -28,7 +28,7 @@ func TestAdd(t *testing.T) {
},
},
},
}})
}}, false)
assert.ElementsMatch(t, []string{"0.0.0.1", "0.0.0.2", "0.0.0.3"}, endpoints)
}
@@ -51,7 +51,7 @@ func TestDelete(t *testing.T) {
},
},
},
}})
}}, false)
h.OnDelete("bad")
h.OnDelete(&v1.Endpoints{Subsets: []v1.EndpointSubset{
{
@@ -167,7 +167,7 @@ func TestUpdateChangeWithDifferentVersion(t *testing.T) {
},
},
},
}})
}}, false)
h.OnUpdate(&v1.Endpoints{
Subsets: []v1.EndpointSubset{
{
@@ -220,7 +220,7 @@ func TestUpdateNoChangeWithDifferentVersion(t *testing.T) {
},
},
},
}})
}}, false)
h.OnUpdate("bad", &v1.Endpoints{Subsets: []v1.EndpointSubset{
{
Addresses: []v1.EndpointAddress{