Skip to content

Commit

Permalink
handle objects from cache of type DeletedFinalStateUnknown (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsgstrabo authored Nov 6, 2024
1 parent 018b323 commit 0861231
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions replicate/common/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package common

import (
"fmt"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"reflect"
"regexp"
"sort"
"strings"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
)

func GetKeysFromBinaryMap(data map[string][]byte) []string {
Expand Down Expand Up @@ -48,10 +50,13 @@ func MustGetObject(obj interface{}) metav1.Object {
return nil
}

if oma, ok := obj.(metav1.ObjectMetaAccessor); ok {
return oma.GetObjectMeta()
} else if o, ok := obj.(metav1.Object); ok {
switch o := obj.(type) {
case metav1.ObjectMetaAccessor:
return o.GetObjectMeta()
case metav1.Object:
return o
case cache.DeletedFinalStateUnknown:
return MustGetObject(o.Obj)
}

panic(errors.Errorf("Unknown type: %v", reflect.TypeOf(obj)))
Expand Down

0 comments on commit 0861231

Please sign in to comment.