@@ -21,7 +21,6 @@ import (
21
21
"fmt"
22
22
"strings"
23
23
24
- "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
25
24
"k8s.io/apimachinery/pkg/runtime"
26
25
)
27
26
@@ -35,12 +34,12 @@ type unstructuredClient struct {
35
34
36
35
// Create implements client.Client.
37
36
func (uc * unstructuredClient ) Create (ctx context.Context , obj Object , opts ... CreateOption ) error {
38
- u , ok := obj .(* unstructured .Unstructured )
37
+ u , ok := obj .(runtime .Unstructured )
39
38
if ! ok {
40
39
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
41
40
}
42
41
43
- gvk := u .GroupVersionKind ()
42
+ gvk := u .GetObjectKind (). GroupVersionKind ()
44
43
45
44
o , err := uc .resources .getObjMeta (obj )
46
45
if err != nil {
@@ -58,18 +57,18 @@ func (uc *unstructuredClient) Create(ctx context.Context, obj Object, opts ...Cr
58
57
Do (ctx ).
59
58
Into (obj )
60
59
61
- u .SetGroupVersionKind (gvk )
60
+ u .GetObjectKind (). SetGroupVersionKind (gvk )
62
61
return result
63
62
}
64
63
65
64
// Update implements client.Client.
66
65
func (uc * unstructuredClient ) Update (ctx context.Context , obj Object , opts ... UpdateOption ) error {
67
- u , ok := obj .(* unstructured .Unstructured )
66
+ u , ok := obj .(runtime .Unstructured )
68
67
if ! ok {
69
68
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
70
69
}
71
70
72
- gvk := u .GroupVersionKind ()
71
+ gvk := u .GetObjectKind (). GroupVersionKind ()
73
72
74
73
o , err := uc .resources .getObjMeta (obj )
75
74
if err != nil {
@@ -88,13 +87,13 @@ func (uc *unstructuredClient) Update(ctx context.Context, obj Object, opts ...Up
88
87
Do (ctx ).
89
88
Into (obj )
90
89
91
- u .SetGroupVersionKind (gvk )
90
+ u .GetObjectKind (). SetGroupVersionKind (gvk )
92
91
return result
93
92
}
94
93
95
94
// Delete implements client.Client.
96
95
func (uc * unstructuredClient ) Delete (ctx context.Context , obj Object , opts ... DeleteOption ) error {
97
- if _ , ok := obj .(* unstructured .Unstructured ); ! ok {
96
+ if _ , ok := obj .(runtime .Unstructured ); ! ok {
98
97
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
99
98
}
100
99
@@ -117,7 +116,7 @@ func (uc *unstructuredClient) Delete(ctx context.Context, obj Object, opts ...De
117
116
118
117
// DeleteAllOf implements client.Client.
119
118
func (uc * unstructuredClient ) DeleteAllOf (ctx context.Context , obj Object , opts ... DeleteAllOfOption ) error {
120
- if _ , ok := obj .(* unstructured .Unstructured ); ! ok {
119
+ if _ , ok := obj .(runtime .Unstructured ); ! ok {
121
120
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
122
121
}
123
122
@@ -140,7 +139,7 @@ func (uc *unstructuredClient) DeleteAllOf(ctx context.Context, obj Object, opts
140
139
141
140
// Patch implements client.Client.
142
141
func (uc * unstructuredClient ) Patch (ctx context.Context , obj Object , patch Patch , opts ... PatchOption ) error {
143
- if _ , ok := obj .(* unstructured .Unstructured ); ! ok {
142
+ if _ , ok := obj .(runtime .Unstructured ); ! ok {
144
143
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
145
144
}
146
145
@@ -169,12 +168,12 @@ func (uc *unstructuredClient) Patch(ctx context.Context, obj Object, patch Patch
169
168
170
169
// Get implements client.Client.
171
170
func (uc * unstructuredClient ) Get (ctx context.Context , key ObjectKey , obj Object , opts ... GetOption ) error {
172
- u , ok := obj .(* unstructured .Unstructured )
171
+ u , ok := obj .(runtime .Unstructured )
173
172
if ! ok {
174
173
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
175
174
}
176
175
177
- gvk := u .GroupVersionKind ()
176
+ gvk := u .GetObjectKind (). GroupVersionKind ()
178
177
179
178
getOpts := GetOptions {}
180
179
getOpts .ApplyOptions (opts )
@@ -192,19 +191,19 @@ func (uc *unstructuredClient) Get(ctx context.Context, key ObjectKey, obj Object
192
191
Do (ctx ).
193
192
Into (obj )
194
193
195
- u .SetGroupVersionKind (gvk )
194
+ u .GetObjectKind (). SetGroupVersionKind (gvk )
196
195
197
196
return result
198
197
}
199
198
200
199
// List implements client.Client.
201
200
func (uc * unstructuredClient ) List (ctx context.Context , obj ObjectList , opts ... ListOption ) error {
202
- u , ok := obj .(* unstructured. UnstructuredList )
201
+ u , ok := obj .(runtime. Unstructured )
203
202
if ! ok {
204
203
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
205
204
}
206
205
207
- gvk := u .GroupVersionKind ()
206
+ gvk := u .GetObjectKind (). GroupVersionKind ()
208
207
gvk .Kind = strings .TrimSuffix (gvk .Kind , "List" )
209
208
210
209
r , err := uc .resources .getResource (obj )
@@ -224,11 +223,11 @@ func (uc *unstructuredClient) List(ctx context.Context, obj ObjectList, opts ...
224
223
}
225
224
226
225
func (uc * unstructuredClient ) GetSubResource (ctx context.Context , obj , subResourceObj Object , subResource string , opts ... SubResourceGetOption ) error {
227
- if _ , ok := obj .(* unstructured .Unstructured ); ! ok {
226
+ if _ , ok := obj .(runtime .Unstructured ); ! ok {
228
227
return fmt .Errorf ("unstructured client did not understand object: %T" , subResource )
229
228
}
230
229
231
- if _ , ok := subResourceObj .(* unstructured .Unstructured ); ! ok {
230
+ if _ , ok := subResourceObj .(runtime .Unstructured ); ! ok {
232
231
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
233
232
}
234
233
@@ -255,11 +254,11 @@ func (uc *unstructuredClient) GetSubResource(ctx context.Context, obj, subResour
255
254
}
256
255
257
256
func (uc * unstructuredClient ) CreateSubResource (ctx context.Context , obj , subResourceObj Object , subResource string , opts ... SubResourceCreateOption ) error {
258
- if _ , ok := obj .(* unstructured .Unstructured ); ! ok {
257
+ if _ , ok := obj .(runtime .Unstructured ); ! ok {
259
258
return fmt .Errorf ("unstructured client did not understand object: %T" , subResourceObj )
260
259
}
261
260
262
- if _ , ok := subResourceObj .(* unstructured .Unstructured ); ! ok {
261
+ if _ , ok := subResourceObj .(runtime .Unstructured ); ! ok {
263
262
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
264
263
}
265
264
@@ -287,7 +286,7 @@ func (uc *unstructuredClient) CreateSubResource(ctx context.Context, obj, subRes
287
286
}
288
287
289
288
func (uc * unstructuredClient ) UpdateSubResource (ctx context.Context , obj Object , subResource string , opts ... SubResourceUpdateOption ) error {
290
- if _ , ok := obj .(* unstructured .Unstructured ); ! ok {
289
+ if _ , ok := obj .(runtime .Unstructured ); ! ok {
291
290
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
292
291
}
293
292
@@ -322,12 +321,12 @@ func (uc *unstructuredClient) UpdateSubResource(ctx context.Context, obj Object,
322
321
}
323
322
324
323
func (uc * unstructuredClient ) PatchSubResource (ctx context.Context , obj Object , subResource string , patch Patch , opts ... SubResourcePatchOption ) error {
325
- u , ok := obj .(* unstructured .Unstructured )
324
+ u , ok := obj .(runtime .Unstructured )
326
325
if ! ok {
327
326
return fmt .Errorf ("unstructured client did not understand object: %T" , obj )
328
327
}
329
328
330
- gvk := u .GroupVersionKind ()
329
+ gvk := u .GetObjectKind (). GroupVersionKind ()
331
330
332
331
o , err := uc .resources .getObjMeta (obj )
333
332
if err != nil {
@@ -357,6 +356,6 @@ func (uc *unstructuredClient) PatchSubResource(ctx context.Context, obj Object,
357
356
Do (ctx ).
358
357
Into (body )
359
358
360
- u .SetGroupVersionKind (gvk )
359
+ u .GetObjectKind (). SetGroupVersionKind (gvk )
361
360
return result
362
361
}
0 commit comments