@@ -27,6 +27,7 @@ import (
27
27
"testing"
28
28
29
29
"github.com/stretchr/testify/require"
30
+ apps "k8s.io/api/apps/v1"
30
31
batch "k8s.io/api/batch/v1"
31
32
core "k8s.io/api/core/v1"
32
33
rbac "k8s.io/api/rbac/v1"
@@ -120,12 +121,24 @@ func CreateObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientSe
120
121
vl := * v
121
122
_ , err := k8s .CoreV1 ().Secrets (vl .GetNamespace ()).Create (context .Background (), vl , meta.CreateOptions {})
122
123
require .NoError (t , err )
124
+ case * * core.Service :
125
+ require .NotNil (t , v )
126
+
127
+ vl := * v
128
+ _ , err := k8s .CoreV1 ().Services (vl .GetNamespace ()).Create (context .Background (), vl , meta.CreateOptions {})
129
+ require .NoError (t , err )
123
130
case * * core.ServiceAccount :
124
131
require .NotNil (t , v )
125
132
126
133
vl := * v
127
134
_ , err := k8s .CoreV1 ().ServiceAccounts (vl .GetNamespace ()).Create (context .Background (), vl , meta.CreateOptions {})
128
135
require .NoError (t , err )
136
+ case * * apps.StatefulSet :
137
+ require .NotNil (t , v )
138
+
139
+ vl := * v
140
+ _ , err := k8s .AppsV1 ().StatefulSets (vl .GetNamespace ()).Create (context .Background (), vl , meta.CreateOptions {})
141
+ require .NoError (t , err )
129
142
case * * api.ArangoDeployment :
130
143
require .NotNil (t , v )
131
144
@@ -223,12 +236,23 @@ func UpdateObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientSe
223
236
vl := * v
224
237
_ , err := k8s .CoreV1 ().Secrets (vl .GetNamespace ()).Update (context .Background (), vl , meta.UpdateOptions {})
225
238
require .NoError (t , err )
239
+ case * * core.Service :
240
+ require .NotNil (t , v )
241
+
242
+ vl := * v
243
+ _ , err := k8s .CoreV1 ().Services (vl .GetNamespace ()).Update (context .Background (), vl , meta.UpdateOptions {})
244
+ require .NoError (t , err )
226
245
case * * core.ServiceAccount :
227
246
require .NotNil (t , v )
228
247
229
248
vl := * v
230
249
_ , err := k8s .CoreV1 ().ServiceAccounts (vl .GetNamespace ()).Update (context .Background (), vl , meta.UpdateOptions {})
231
250
require .NoError (t , err )
251
+ case * * apps.StatefulSet :
252
+ require .NotNil (t , v )
253
+ vl := * v
254
+ _ , err := k8s .AppsV1 ().StatefulSets (vl .GetNamespace ()).Update (context .Background (), vl , meta.UpdateOptions {})
255
+ require .NoError (t , err )
232
256
case * * api.ArangoDeployment :
233
257
require .NotNil (t , v )
234
258
@@ -450,6 +474,21 @@ func RefreshObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientS
450
474
} else {
451
475
* v = vn
452
476
}
477
+ case * * core.Service :
478
+ require .NotNil (t , v )
479
+
480
+ vl := * v
481
+
482
+ vn , err := k8s .CoreV1 ().Services (vl .GetNamespace ()).Get (context .Background (), vl .GetName (), meta.GetOptions {})
483
+ if err != nil {
484
+ if kerrors .IsNotFound (err ) {
485
+ * v = nil
486
+ } else {
487
+ require .NoError (t , err )
488
+ }
489
+ } else {
490
+ * v = vn
491
+ }
453
492
case * * core.ServiceAccount :
454
493
require .NotNil (t , v )
455
494
@@ -465,6 +504,20 @@ func RefreshObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientS
465
504
} else {
466
505
* v = vn
467
506
}
507
+ case * * apps.StatefulSet :
508
+ require .NotNil (t , v )
509
+
510
+ vl := * v
511
+ vn , err := k8s .AppsV1 ().StatefulSets (vl .GetNamespace ()).Get (context .Background (), vl .GetName (), meta.GetOptions {})
512
+ if err != nil {
513
+ if kerrors .IsNotFound (err ) {
514
+ * v = nil
515
+ } else {
516
+ require .NoError (t , err )
517
+ }
518
+ } else {
519
+ * v = vn
520
+ }
468
521
case * * api.ArangoDeployment :
469
522
require .NotNil (t , v )
470
523
@@ -616,7 +669,7 @@ func RefreshObjects(t *testing.T, k8s kubernetes.Interface, arango arangoClientS
616
669
* v = vn
617
670
}
618
671
default :
619
- require .Fail (t , fmt .Sprintf ("Unable to create object: %s" , reflect .TypeOf (v ).String ()))
672
+ require .Fail (t , fmt .Sprintf ("Unable to get object: %s" , reflect .TypeOf (v ).String ()))
620
673
}
621
674
}
622
675
}
@@ -649,12 +702,24 @@ func SetMetaBasedOnType(t *testing.T, object meta.Object) {
649
702
v .SetSelfLink (fmt .Sprintf ("/api/v1/secrets/%s/%s" ,
650
703
object .GetNamespace (),
651
704
object .GetName ()))
705
+ case * core.Service :
706
+ v .Kind = "Service"
707
+ v .APIVersion = "v1"
708
+ v .SetSelfLink (fmt .Sprintf ("/api/v1/services/%s/%s" ,
709
+ object .GetNamespace (),
710
+ object .GetName ()))
652
711
case * core.ServiceAccount :
653
712
v .Kind = "ServiceAccount"
654
713
v .APIVersion = "v1"
655
714
v .SetSelfLink (fmt .Sprintf ("/api/v1/serviceaccounts/%s/%s" ,
656
715
object .GetNamespace (),
657
716
object .GetName ()))
717
+ case * apps.StatefulSet :
718
+ v .Kind = "StatefulSet"
719
+ v .APIVersion = "v1"
720
+ v .SetSelfLink (fmt .Sprintf ("/api/apps/v1/statefulsets/%s/%s" ,
721
+ object .GetNamespace (),
722
+ object .GetName ()))
658
723
case * api.ArangoDeployment :
659
724
v .Kind = deployment .ArangoDeploymentResourceKind
660
725
v .APIVersion = api .SchemeGroupVersion .String ()
@@ -790,10 +855,18 @@ func NewItem(t *testing.T, o operation.Operation, object meta.Object) operation.
790
855
item .Group = ""
791
856
item .Version = "v1"
792
857
item .Kind = "Secret"
858
+ case * core.Service :
859
+ item .Group = ""
860
+ item .Version = "v1"
861
+ item .Kind = "Service"
793
862
case * core.ServiceAccount :
794
863
item .Group = ""
795
864
item .Version = "v1"
796
865
item .Kind = "ServiceAccount"
866
+ case * apps.StatefulSet :
867
+ item .Group = "apps"
868
+ item .Version = "v1"
869
+ item .Kind = "StatefulSet"
797
870
case * api.ArangoDeployment :
798
871
item .Group = deployment .ArangoDeploymentGroupName
799
872
item .Version = api .ArangoDeploymentVersion
0 commit comments