plugin/kubernetes: fix tombstone unwrapping (#3924)
* fix tombstone unwrapping Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
parent
d35c8e9eda
commit
d902e85919
4 changed files with 163 additions and 83 deletions
|
@ -1,6 +1,8 @@
|
|||
package object
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
@ -43,8 +45,19 @@ type EndpointPort struct {
|
|||
// EndpointsKey return a string using for the index.
|
||||
func EndpointsKey(name, namespace string) string { return name + "." + namespace }
|
||||
|
||||
// ToEndpoints converts an api.Endpoints to a *Endpoints.
|
||||
func ToEndpoints(end *api.Endpoints) *Endpoints {
|
||||
// ToEndpoints returns a function that converts an *api.Endpoints to a *Endpoints.
|
||||
func ToEndpoints(skipCleanup bool) ToFunc {
|
||||
return func(obj interface{}) (interface{}, error) {
|
||||
eps, ok := obj.(*api.Endpoints)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected object %v", obj)
|
||||
}
|
||||
return toEndpoints(skipCleanup, eps), nil
|
||||
}
|
||||
}
|
||||
|
||||
// toEndpoints converts an *api.Endpoints to a *Endpoints.
|
||||
func toEndpoints(skipCleanup bool, end *api.Endpoints) *Endpoints {
|
||||
e := &Endpoints{
|
||||
Version: end.GetResourceVersion(),
|
||||
Name: end.GetName(),
|
||||
|
@ -88,6 +101,10 @@ func ToEndpoints(end *api.Endpoints) *Endpoints {
|
|||
}
|
||||
}
|
||||
|
||||
if !skipCleanup {
|
||||
*end = api.Endpoints{}
|
||||
}
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue