@@ -195,27 +195,53 @@ func (c *TestSuite) list(ctx context.Context, list client.ObjectList, opts []cli
195
195
}
196
196
}
197
197
198
+ func DebugFormat (obj client.Object ) string {
199
+ var s string
200
+ gvk := obj .GetObjectKind ().GroupVersionKind ()
201
+ if gvk .Empty () {
202
+ s = fmt .Sprintf ("%T" , obj )
203
+ } else {
204
+ s = gvk .Kind
205
+ }
206
+ ns := obj .GetNamespace ()
207
+ if ns != "" {
208
+ s += " " + ns + "/"
209
+ } else {
210
+ s += " "
211
+ }
212
+ s += obj .GetName ()
213
+ return s
214
+ }
215
+
198
216
func (c * TestSuite ) create (ctx context.Context , obj client.Object , opts []client.CreateOption , eh ErrorHandler ) {
217
+ c .Logf ("creating object %v" , DebugFormat (obj ))
218
+
199
219
if err := c .client .Create (ctx , obj , opts ... ); err != nil {
200
- eh ("failed to create resource %s %s/%s : %v" , obj . GetObjectKind (). GroupVersionKind (), obj . GetNamespace (), obj . GetName ( ), err )
220
+ eh ("failed to create resource %s: %v" , DebugFormat ( obj ), err )
201
221
}
202
222
}
203
223
204
224
func (c * TestSuite ) delete (ctx context.Context , obj client.Object , opts []client.DeleteOption , eh ErrorHandler ) {
225
+ c .Logf ("deleting object %v" , DebugFormat (obj ))
226
+
205
227
if err := c .client .Delete (ctx , obj , opts ... ); err != nil {
206
- eh ("failed to delete resource %s %s/%s : %v" , obj . GetObjectKind (). GroupVersionKind (), obj . GetNamespace (), obj . GetName ( ), err )
228
+ eh ("failed to delete resource %s: %v" , DebugFormat ( obj ), err )
207
229
}
208
230
}
209
231
210
232
func (t * TestSuite ) update (ctx context.Context , obj client.Object , opts []client.UpdateOption , eh ErrorHandler ) {
233
+ t .Logf ("updating object %v" , DebugFormat (obj ))
234
+
211
235
if err := t .client .Update (ctx , obj , opts ... ); err != nil {
212
- eh ("failed to update resource %s %s/%s : %v" , obj . GetObjectKind (). GroupVersionKind (), obj . GetNamespace (), obj . GetName ( ), err )
236
+ eh ("failed to update resource %s: %v" , DebugFormat ( obj ), err )
213
237
}
214
238
}
215
239
216
240
func (t * TestSuite ) patch (ctx context.Context , obj client.Object , patch client.Patch , opts []client.PatchOption , eh ErrorHandler ) {
241
+ t .Logf ("patching object %v" , DebugFormat (obj ))
242
+
217
243
if err := t .client .Patch (ctx , obj , patch , opts ... ); err != nil {
218
- eh ("failed to patch resource %s %s/%s : %v" , obj . GetObjectKind (). GroupVersionKind (), obj . GetNamespace (), obj . GetName ( ), err )
244
+ eh ("failed to patch resource %s: %v" , DebugFormat ( obj ), err )
219
245
}
220
246
}
221
247
0 commit comments