@@ -24,7 +24,6 @@ import (
24
24
"k8s.io/apimachinery/pkg/api/meta"
25
25
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
26
26
"k8s.io/apimachinery/pkg/runtime"
27
- "k8s.io/apimachinery/pkg/runtime/schema"
28
27
"k8s.io/apimachinery/pkg/runtime/serializer"
29
28
"k8s.io/client-go/dynamic"
30
29
"k8s.io/client-go/kubernetes/scheme"
@@ -104,16 +103,6 @@ type client struct {
104
103
unstructuredClient unstructuredClient
105
104
}
106
105
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
-
117
106
// Create implements client.Client
118
107
func (c * client ) Create (ctx context.Context , obj runtime.Object , opts ... CreateOption ) error {
119
108
_ , ok := obj .(* unstructured.Unstructured )
@@ -125,7 +114,6 @@ func (c *client) Create(ctx context.Context, obj runtime.Object, opts ...CreateO
125
114
126
115
// Update implements client.Client
127
116
func (c * client ) Update (ctx context.Context , obj runtime.Object , opts ... UpdateOption ) error {
128
- defer c .resetGroupVersionKind (obj , obj .GetObjectKind ().GroupVersionKind ())
129
117
_ , ok := obj .(* unstructured.Unstructured )
130
118
if ok {
131
119
return c .unstructuredClient .Update (ctx , obj , opts ... )
@@ -153,7 +141,6 @@ func (c *client) DeleteAllOf(ctx context.Context, obj runtime.Object, opts ...De
153
141
154
142
// Patch implements client.Client
155
143
func (c * client ) Patch (ctx context.Context , obj runtime.Object , patch Patch , opts ... PatchOption ) error {
156
- defer c .resetGroupVersionKind (obj , obj .GetObjectKind ().GroupVersionKind ())
157
144
_ , ok := obj .(* unstructured.Unstructured )
158
145
if ok {
159
146
return c .unstructuredClient .Patch (ctx , obj , patch , opts ... )
@@ -194,7 +181,6 @@ var _ StatusWriter = &statusWriter{}
194
181
195
182
// Update implements client.StatusWriter
196
183
func (sw * statusWriter ) Update (ctx context.Context , obj runtime.Object , opts ... UpdateOption ) error {
197
- defer sw .client .resetGroupVersionKind (obj , obj .GetObjectKind ().GroupVersionKind ())
198
184
_ , ok := obj .(* unstructured.Unstructured )
199
185
if ok {
200
186
return sw .client .unstructuredClient .UpdateStatus (ctx , obj , opts ... )
@@ -204,7 +190,6 @@ func (sw *statusWriter) Update(ctx context.Context, obj runtime.Object, opts ...
204
190
205
191
// Patch implements client.Client
206
192
func (sw * statusWriter ) Patch (ctx context.Context , obj runtime.Object , patch Patch , opts ... PatchOption ) error {
207
- defer sw .client .resetGroupVersionKind (obj , obj .GetObjectKind ().GroupVersionKind ())
208
193
_ , ok := obj .(* unstructured.Unstructured )
209
194
if ok {
210
195
return sw .client .unstructuredClient .PatchStatus (ctx , obj , patch , opts ... )
0 commit comments