@@ -22,6 +22,7 @@ import (
22
22
. "github.com/onsi/ginkgo/v2"
23
23
. "github.com/onsi/gomega"
24
24
25
+ corev1 "k8s.io/api/core/v1"
25
26
"k8s.io/apimachinery/pkg/api/errors"
26
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
28
"k8s.io/apimachinery/pkg/types"
@@ -43,8 +44,31 @@ var _ = Describe("Shard Controller", func() {
43
44
shard := & operatorv1alpha1.Shard {}
44
45
45
46
BeforeEach (func () {
47
+ By ("creating the custom resource for the Kind RootShard" )
48
+ err := k8sClient .Get (ctx , typeNamespacedName , & operatorv1alpha1.RootShard {})
49
+ if err != nil && errors .IsNotFound (err ) {
50
+ resource := & operatorv1alpha1.RootShard {
51
+ ObjectMeta : metav1.ObjectMeta {
52
+ Name : "my-root-shard" ,
53
+ Namespace : "default" ,
54
+ },
55
+ Spec : operatorv1alpha1.RootShardSpec {
56
+ External : operatorv1alpha1.ExternalConfig {
57
+ Hostname : "example.kcp.io" ,
58
+ Port : 6443 ,
59
+ },
60
+ CommonShardSpec : operatorv1alpha1.CommonShardSpec {
61
+ Etcd : operatorv1alpha1.EtcdConfig {
62
+ Endpoints : []string {"https://localhost:2379" },
63
+ },
64
+ },
65
+ },
66
+ }
67
+ Expect (k8sClient .Create (ctx , resource )).To (Succeed ())
68
+ }
69
+
46
70
By ("creating the custom resource for the Kind Shard" )
47
- err : = k8sClient .Get (ctx , typeNamespacedName , shard )
71
+ err = k8sClient .Get (ctx , typeNamespacedName , shard )
48
72
if err != nil && errors .IsNotFound (err ) {
49
73
resource := & operatorv1alpha1.Shard {
50
74
ObjectMeta : metav1.ObjectMeta {
@@ -57,6 +81,11 @@ var _ = Describe("Shard Controller", func() {
57
81
Endpoints : []string {"https://localhost:2379" },
58
82
},
59
83
},
84
+ RootShard : operatorv1alpha1.RootShardConfig {
85
+ Reference : & corev1.LocalObjectReference {
86
+ Name : "my-root-shard" ,
87
+ },
88
+ },
60
89
},
61
90
}
62
91
Expect (k8sClient .Create (ctx , resource )).To (Succeed ())
0 commit comments