@@ -25,9 +25,7 @@ import (
25
25
"k8s.io/client-go/discovery"
26
26
"k8s.io/client-go/kubernetes"
27
27
"k8s.io/client-go/rest"
28
- "k8s.io/klog/v2"
29
28
30
- apierrors "k8s.io/apimachinery/pkg/api/errors"
31
29
"openebs.io/metac/dynamic/clientset"
32
30
dynamicclientset "openebs.io/metac/dynamic/clientset"
33
31
dynamicdiscovery "openebs.io/metac/dynamic/discovery"
@@ -38,7 +36,6 @@ type UtilityConfig struct {
38
36
KubeConfig * rest.Config
39
37
APIDiscovery * dynamicdiscovery.APIResourceDiscovery
40
38
Retry * Retryable
41
- IsTeardown bool
42
39
}
43
40
44
41
// UtilityFuncs exposes Utility fields as functional options
@@ -72,14 +69,6 @@ type Utility struct {
72
69
// definitions aka CRDs
73
70
crdClient apiextnv1beta1.ApiextensionsV1beta1Interface
74
71
75
- // If resources created using this utility should be deleted
76
- // when this instance's Teardown method is invoked
77
- isTeardown bool
78
-
79
- // list of teardown functions invoked when this instance's
80
- // Teardown method is invoked
81
- teardownFuncs []func () error
82
-
83
72
// error as value
84
73
err error
85
74
}
@@ -136,7 +125,6 @@ func NewUtility(config UtilityConfig) (*Utility, error) {
136
125
// Following order needs to be maintained
137
126
var setters = []func (UtilityConfig ){
138
127
// pre settings
139
- u .setTeardownFlag ,
140
128
u .setAPIResourceDiscoveryOrDefault ,
141
129
142
130
// post settings
@@ -153,10 +141,6 @@ func NewUtility(config UtilityConfig) (*Utility, error) {
153
141
return u , nil
154
142
}
155
143
156
- func (u * Utility ) setTeardownFlag (config UtilityConfig ) {
157
- u .isTeardown = config .IsTeardown
158
- }
159
-
160
144
func (u * Utility ) setAPIResourceDiscoveryOrDefault (config UtilityConfig ) {
161
145
u .apiResourceDiscovery = config .APIDiscovery
162
146
if u .apiResourceDiscovery != nil {
@@ -205,64 +189,6 @@ func (u *Utility) setKubeClientset(config UtilityConfig) {
205
189
)
206
190
}
207
191
208
- // MustTeardown deletes resources created through this instance
209
- func (u * Utility ) MustTeardown () {
210
- // cleanup in descending order
211
- for i := len (u .teardownFuncs ) - 1 ; i >= 0 ; i -- {
212
- teardown := u .teardownFuncs [i ]
213
- err := teardown ()
214
- if err != nil {
215
- if apierrors .IsNotFound (err ) {
216
- klog .V (3 ).Infof (
217
- "Teardown ignored: Resource not found: %+v" ,
218
- err ,
219
- )
220
- continue
221
- }
222
- if apierrors .IsConflict (err ) {
223
- klog .V (3 ).Infof (
224
- "Teardown ignored: Conflict: %+v" ,
225
- err ,
226
- )
227
- continue
228
- }
229
- // we treat the teardown error as level 1 Info
230
- klog .V (1 ).Infof (
231
- "Teardown failed: %s: %+v" ,
232
- apierrors .ReasonForError (err ),
233
- err ,
234
- )
235
- }
236
- }
237
- }
238
-
239
- // Teardown optionally deletes resources created through this
240
- // instance
241
- func (u * Utility ) Teardown () {
242
- if ! u .isTeardown {
243
- return
244
- }
245
- u .MustTeardown ()
246
- }
247
-
248
- // MustAddToTeardown adds the given teardown function to
249
- // the list of teardown functions
250
- func (u * Utility ) MustAddToTeardown (teardown func () error ) {
251
- if teardown == nil {
252
- return
253
- }
254
- u .teardownFuncs = append (u .teardownFuncs , teardown )
255
- }
256
-
257
- // AddToTeardown optionally adds the given teardown function to
258
- // the list of teardown functions
259
- func (u * Utility ) AddToTeardown (teardown func () error ) {
260
- if ! u .isTeardown {
261
- return
262
- }
263
- u .MustAddToTeardown (teardown )
264
- }
265
-
266
192
// GetClientForAPIVersionAndKind returns the dynamic client for the
267
193
// given api version & kind
268
194
func (u * Utility ) GetClientForAPIVersionAndKind (
0 commit comments