Skip to content

Commit d7d38e8

Browse files
committed
remove unnecessary resetGroupVersionKind function and its calls
1 parent 3319872 commit d7d38e8

File tree

1 file changed

+0
-15
lines changed

1 file changed

+0
-15
lines changed

pkg/client/client.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"k8s.io/apimachinery/pkg/api/meta"
2525
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2626
"k8s.io/apimachinery/pkg/runtime"
27-
"k8s.io/apimachinery/pkg/runtime/schema"
2827
"k8s.io/apimachinery/pkg/runtime/serializer"
2928
"k8s.io/client-go/dynamic"
3029
"k8s.io/client-go/kubernetes/scheme"
@@ -104,16 +103,6 @@ type client struct {
104103
unstructuredClient unstructuredClient
105104
}
106105

107-
// resetGroupVersionKind is a helper function to restore and preserve GroupVersionKind on an object.
108-
// TODO(vincepri): Remove this function and its calls once controller-runtime dependencies are upgraded to 1.15.
109-
func (c *client) resetGroupVersionKind(obj runtime.Object, gvk schema.GroupVersionKind) {
110-
if gvk != schema.EmptyObjectKind.GroupVersionKind() {
111-
if v, ok := obj.(schema.ObjectKind); ok {
112-
v.SetGroupVersionKind(gvk)
113-
}
114-
}
115-
}
116-
117106
// Create implements client.Client
118107
func (c *client) Create(ctx context.Context, obj runtime.Object, opts ...CreateOption) error {
119108
_, ok := obj.(*unstructured.Unstructured)
@@ -125,7 +114,6 @@ func (c *client) Create(ctx context.Context, obj runtime.Object, opts ...CreateO
125114

126115
// Update implements client.Client
127116
func (c *client) Update(ctx context.Context, obj runtime.Object, opts ...UpdateOption) error {
128-
defer c.resetGroupVersionKind(obj, obj.GetObjectKind().GroupVersionKind())
129117
_, ok := obj.(*unstructured.Unstructured)
130118
if ok {
131119
return c.unstructuredClient.Update(ctx, obj, opts...)
@@ -153,7 +141,6 @@ func (c *client) DeleteAllOf(ctx context.Context, obj runtime.Object, opts ...De
153141

154142
// Patch implements client.Client
155143
func (c *client) Patch(ctx context.Context, obj runtime.Object, patch Patch, opts ...PatchOption) error {
156-
defer c.resetGroupVersionKind(obj, obj.GetObjectKind().GroupVersionKind())
157144
_, ok := obj.(*unstructured.Unstructured)
158145
if ok {
159146
return c.unstructuredClient.Patch(ctx, obj, patch, opts...)
@@ -194,7 +181,6 @@ var _ StatusWriter = &statusWriter{}
194181

195182
// Update implements client.StatusWriter
196183
func (sw *statusWriter) Update(ctx context.Context, obj runtime.Object, opts ...UpdateOption) error {
197-
defer sw.client.resetGroupVersionKind(obj, obj.GetObjectKind().GroupVersionKind())
198184
_, ok := obj.(*unstructured.Unstructured)
199185
if ok {
200186
return sw.client.unstructuredClient.UpdateStatus(ctx, obj, opts...)
@@ -204,7 +190,6 @@ func (sw *statusWriter) Update(ctx context.Context, obj runtime.Object, opts ...
204190

205191
// Patch implements client.Client
206192
func (sw *statusWriter) Patch(ctx context.Context, obj runtime.Object, patch Patch, opts ...PatchOption) error {
207-
defer sw.client.resetGroupVersionKind(obj, obj.GetObjectKind().GroupVersionKind())
208193
_, ok := obj.(*unstructured.Unstructured)
209194
if ok {
210195
return sw.client.unstructuredClient.PatchStatus(ctx, obj, patch, opts...)

0 commit comments

Comments
 (0)