Skip to content

Commit

Permalink
Make resource helpers scheme configurable through exported variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rzetelskik committed Mar 4, 2024
1 parent a67e979 commit 614562b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/resource/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

var Scheme = scheme.Scheme

func newUnknownGVK() *schema.GroupVersionKind {
return &schema.GroupVersionKind{
Group: "unknown",
Expand All @@ -23,7 +25,7 @@ func GetObjectGVK(object runtime.Object) (*schema.GroupVersionKind, error) {
return &gvk, nil
}

kinds, _, err := scheme.Scheme.ObjectKinds(object)
kinds, _, err := Scheme.ObjectKinds(object)
if err != nil {
return nil, err
}
Expand All @@ -40,7 +42,7 @@ func GetObjectGVKOrUnknown(obj runtime.Object) *schema.GroupVersionKind {
return &gvk
}

kinds, _, err := scheme.Scheme.ObjectKinds(obj)
kinds, _, err := Scheme.ObjectKinds(obj)
if err != nil || len(kinds) == 0 {
t := reflect.TypeOf(obj)
if t.Kind() == reflect.Ptr {
Expand Down

0 comments on commit 614562b

Please sign in to comment.