fix golint issues (#992)

This commit is contained in:
Kevin Wan
2021-09-04 12:16:30 +08:00
committed by GitHub
parent 20f665ede8
commit 9bdadf2381
14 changed files with 68 additions and 77 deletions

View File

@@ -8,12 +8,14 @@ import (
v1 "k8s.io/api/core/v1"
)
// EventHandler is ResourceEventHandler implementation.
type EventHandler struct {
update func([]string)
endpoints map[string]lang.PlaceholderType
lock sync.Mutex
}
// NewEventHandler returns an EventHandler.
func NewEventHandler(update func([]string)) *EventHandler {
return &EventHandler{
update: update,
@@ -21,6 +23,7 @@ func NewEventHandler(update func([]string)) *EventHandler {
}
}
// OnAdd handles the endpoints add events.
func (h *EventHandler) OnAdd(obj interface{}) {
endpoints, ok := obj.(*v1.Endpoints)
if !ok {
@@ -46,6 +49,7 @@ func (h *EventHandler) OnAdd(obj interface{}) {
}
}
// OnDelete handles the endpoints delete events.
func (h *EventHandler) OnDelete(obj interface{}) {
endpoints, ok := obj.(*v1.Endpoints)
if !ok {
@@ -71,6 +75,7 @@ func (h *EventHandler) OnDelete(obj interface{}) {
}
}
// OnUpdate handles the endpoints update events.
func (h *EventHandler) OnUpdate(oldObj, newObj interface{}) {
oldEndpoints, ok := oldObj.(*v1.Endpoints)
if !ok {
@@ -91,6 +96,7 @@ func (h *EventHandler) OnUpdate(oldObj, newObj interface{}) {
h.Update(newEndpoints)
}
// Update updates the endpoints.
func (h *EventHandler) Update(endpoints *v1.Endpoints) {
h.lock.Lock()
defer h.lock.Unlock()

View File

@@ -15,12 +15,14 @@ const (
var emptyService Service
// Service represents a service with namespace, name and port.
type Service struct {
Namespace string
Name string
Port int
}
// ParseTarget parses the resolver.Target.
func ParseTarget(target resolver.Target) (Service, error) {
var service Service
service.Namespace = target.Authority