@@ -74,6 +74,12 @@ type KubernetesObject interface {
74
74
func CreateObjects (t * testing.T , k8s kubernetes.Interface , arango arangoClientSet.Interface , objects ... interface {}) func (t * testing.T ) {
75
75
for _ , object := range objects {
76
76
switch v := object .(type ) {
77
+ case * * batch.CronJob :
78
+ require .NotNil (t , v )
79
+
80
+ vl := * v
81
+ _ , err := k8s .BatchV1 ().CronJobs (vl .GetNamespace ()).Create (context .Background (), vl , meta.CreateOptions {})
82
+ require .NoError (t , err )
77
83
case * * batch.Job :
78
84
require .NotNil (t , v )
79
85
@@ -122,6 +128,12 @@ func CreateObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientSe
122
128
vl := * v
123
129
_ , err := arango .MlV1alpha1 ().ArangoMLStorages (vl .GetNamespace ()).Create (context .Background (), vl , meta.CreateOptions {})
124
130
require .NoError (t , err )
131
+ case * * mlApi.ArangoMLCronJob :
132
+ require .NotNil (t , v )
133
+
134
+ vl := * v
135
+ _ , err := arango .MlV1alpha1 ().ArangoMLCronJobs (vl .GetNamespace ()).Create (context .Background (), vl , meta.CreateOptions {})
136
+ require .NoError (t , err )
125
137
default :
126
138
require .Fail (t , fmt .Sprintf ("Unable to create object: %s" , reflect .TypeOf (v ).String ()))
127
139
}
@@ -196,6 +208,21 @@ func UpdateObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientSe
196
208
func RefreshObjects (t * testing.T , k8s kubernetes.Interface , arango arangoClientSet.Interface , objects ... interface {}) {
197
209
for _ , object := range objects {
198
210
switch v := object .(type ) {
211
+ case * * batch.CronJob :
212
+ require .NotNil (t , v )
213
+
214
+ vl := * v
215
+
216
+ vn , err := k8s .BatchV1 ().CronJobs (vl .GetNamespace ()).Get (context .Background (), vl .GetName (), meta.GetOptions {})
217
+ if err != nil {
218
+ if kerrors .IsNotFound (err ) {
219
+ * v = nil
220
+ } else {
221
+ require .NoError (t , err )
222
+ }
223
+ } else {
224
+ * v = vn
225
+ }
199
226
case * * batch.Job :
200
227
require .NotNil (t , v )
201
228
@@ -316,6 +343,21 @@ func RefreshObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientS
316
343
} else {
317
344
* v = vn
318
345
}
346
+ case * * mlApi.ArangoMLCronJob :
347
+ require .NotNil (t , v )
348
+
349
+ vl := * v
350
+
351
+ vn , err := arango .MlV1alpha1 ().ArangoMLCronJobs (vl .GetNamespace ()).Get (context .Background (), vl .GetName (), meta.GetOptions {})
352
+ if err != nil {
353
+ if kerrors .IsNotFound (err ) {
354
+ * v = nil
355
+ } else {
356
+ require .NoError (t , err )
357
+ }
358
+ } else {
359
+ * v = vn
360
+ }
319
361
default :
320
362
require .Fail (t , fmt .Sprintf ("Unable to create object: %s" , reflect .TypeOf (v ).String ()))
321
363
}
@@ -326,6 +368,12 @@ type MetaObjectMod[T meta.Object] func(t *testing.T, obj T)
326
368
327
369
func SetMetaBasedOnType (t * testing.T , object meta.Object ) {
328
370
switch v := object .(type ) {
371
+ case * batch.CronJob :
372
+ v .Kind = "CronJob"
373
+ v .APIVersion = "batch/v1"
374
+ v .SetSelfLink (fmt .Sprintf ("/api/batch/v1/cronjobs/%s/%s" ,
375
+ object .GetNamespace (),
376
+ object .GetName ()))
329
377
case * batch.Job :
330
378
v .Kind = "Job"
331
379
v .APIVersion = "batch/v1"
@@ -384,6 +432,14 @@ func SetMetaBasedOnType(t *testing.T, object meta.Object) {
384
432
ml .ArangoMLStorageResourcePlural ,
385
433
object .GetNamespace (),
386
434
object .GetName ()))
435
+ case * mlApi.ArangoMLCronJob :
436
+ v .Kind = ml .ArangoMLCronJobResourceKind
437
+ v .APIVersion = mlApi .SchemeGroupVersion .String ()
438
+ v .SetSelfLink (fmt .Sprintf ("/api/%s/%s/%s/%s" ,
439
+ mlApi .SchemeGroupVersion .String (),
440
+ ml .ArangoMLCronJobResourcePlural ,
441
+ object .GetNamespace (),
442
+ object .GetName ()))
387
443
default :
388
444
require .Fail (t , fmt .Sprintf ("Unable to create object: %s" , reflect .TypeOf (v ).String ()))
389
445
}
@@ -420,6 +476,10 @@ func NewItem(t *testing.T, o operation.Operation, object meta.Object) operation.
420
476
}
421
477
422
478
switch v := object .(type ) {
479
+ case * batch.CronJob :
480
+ item .Group = "batch"
481
+ item .Version = "v1"
482
+ item .Kind = "CronJob"
423
483
case * batch.Job :
424
484
item .Group = "batch"
425
485
item .Version = "v1"
@@ -452,6 +512,10 @@ func NewItem(t *testing.T, o operation.Operation, object meta.Object) operation.
452
512
item .Group = ml .ArangoMLGroupName
453
513
item .Version = mlApi .ArangoMLVersion
454
514
item .Kind = ml .ArangoMLStorageResourceKind
515
+ case * mlApi.ArangoMLCronJob :
516
+ item .Group = ml .ArangoMLGroupName
517
+ item .Version = mlApi .ArangoMLVersion
518
+ item .Kind = ml .ArangoMLCronJobResourceKind
455
519
default :
456
520
require .Fail (t , fmt .Sprintf ("Unable to create object: %s" , reflect .TypeOf (v ).String ()))
457
521
}
0 commit comments