6
6
7
7
"github.com/blang/semver"
8
8
. "github.com/onsi/ginkgo"
9
+ . "github.com/onsi/gomega"
9
10
v1 "github.com/operator-framework/api/pkg/operators/v1"
10
11
"github.com/operator-framework/api/pkg/operators/v1alpha1"
11
12
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
@@ -29,17 +30,17 @@ var _ = Describe("User defined service account", func() {
29
30
crclient := newCRClient ()
30
31
31
32
namespace := genName ("scoped-ns-" )
32
- _ , cleanupNS := newNamespace (GinkgoT (), kubeclient , namespace )
33
+ _ , cleanupNS := newNamespace (kubeclient , namespace )
33
34
defer cleanupNS ()
34
35
35
36
// Create a service account, but add no permission to it.
36
37
saName := genName ("scoped-sa-" )
37
- _ , cleanupSA := newServiceAccount (GinkgoT (), kubeclient , namespace , saName )
38
+ _ , cleanupSA := newServiceAccount (kubeclient , namespace , saName )
38
39
defer cleanupSA ()
39
40
40
41
// Add an OperatorGroup and specify the service account.
41
42
ogName := genName ("scoped-og-" )
42
- _ , cleanupOG := newOperatorGroupWithServiceAccount (GinkgoT (), crclient , namespace , ogName , saName )
43
+ _ , cleanupOG := newOperatorGroupWithServiceAccount (crclient , namespace , ogName , saName )
43
44
defer cleanupOG ()
44
45
45
46
permissions := deploymentPermissions ()
@@ -84,19 +85,19 @@ var _ = Describe("User defined service account", func() {
84
85
crclient := newCRClient ()
85
86
86
87
namespace := genName ("scoped-ns-" )
87
- _ , cleanupNS := newNamespace (GinkgoT (), kubeclient , namespace )
88
+ _ , cleanupNS := newNamespace (kubeclient , namespace )
88
89
defer cleanupNS ()
89
90
90
91
// Create a service account, add enough permission to it so that operator install is successful.
91
92
saName := genName ("scoped-sa" )
92
- _ , cleanupSA := newServiceAccount (GinkgoT (), kubeclient , namespace , saName )
93
+ _ , cleanupSA := newServiceAccount (kubeclient , namespace , saName )
93
94
defer cleanupSA ()
94
95
cleanupPerm := grantPermission (GinkgoT (), kubeclient , namespace , saName )
95
96
defer cleanupPerm ()
96
97
97
98
// Add an OperatorGroup and specify the service account.
98
99
ogName := genName ("scoped-og-" )
99
- _ , cleanupOG := newOperatorGroupWithServiceAccount (GinkgoT (), crclient , namespace , ogName , saName )
100
+ _ , cleanupOG := newOperatorGroupWithServiceAccount (crclient , namespace , ogName , saName )
100
101
defer cleanupOG ()
101
102
102
103
permissions := deploymentPermissions ()
@@ -140,17 +141,17 @@ var _ = Describe("User defined service account", func() {
140
141
crclient := newCRClient ()
141
142
142
143
namespace := genName ("scoped-ns-" )
143
- _ , cleanupNS := newNamespace (GinkgoT (), kubeclient , namespace )
144
+ _ , cleanupNS := newNamespace (kubeclient , namespace )
144
145
defer cleanupNS ()
145
146
146
147
// Create a service account, but add no permission to it.
147
148
saName := genName ("scoped-sa-" )
148
- _ , cleanupSA := newServiceAccount (GinkgoT (), kubeclient , namespace , saName )
149
+ _ , cleanupSA := newServiceAccount (kubeclient , namespace , saName )
149
150
defer cleanupSA ()
150
151
151
152
// Add an OperatorGroup and specify the service account.
152
153
ogName := genName ("scoped-og-" )
153
- _ , cleanupOG := newOperatorGroupWithServiceAccount (GinkgoT (), crclient , namespace , ogName , saName )
154
+ _ , cleanupOG := newOperatorGroupWithServiceAccount (crclient , namespace , ogName , saName )
154
155
defer cleanupOG ()
155
156
156
157
permissions := deploymentPermissions ()
@@ -188,26 +189,26 @@ var _ = Describe("User defined service account", func() {
188
189
})
189
190
})
190
191
191
- func newNamespace (t GinkgoTInterface , client operatorclient.ClientInterface , name string ) (ns * corev1.Namespace , cleanup cleanupFunc ) {
192
+ func newNamespace (client operatorclient.ClientInterface , name string ) (ns * corev1.Namespace , cleanup cleanupFunc ) {
192
193
request := & corev1.Namespace {
193
194
ObjectMeta : metav1.ObjectMeta {
194
195
Name : name ,
195
196
},
196
197
}
197
198
198
199
ns , err := client .KubernetesInterface ().CoreV1 ().Namespaces ().Create (context .TODO (), request , metav1.CreateOptions {})
199
- require . NoError ( t , err )
200
- require . NotNil ( t , ns )
200
+ Expect ( err ). ToNot ( HaveOccurred () )
201
+ Expect ( ns ). ToNot ( BeNil () )
201
202
202
203
cleanup = func () {
203
204
err := client .KubernetesInterface ().CoreV1 ().Namespaces ().Delete (context .TODO (), ns .GetName (), metav1.DeleteOptions {})
204
- require . NoError ( t , err )
205
+ Expect ( err ). ToNot ( HaveOccurred () )
205
206
}
206
207
207
208
return
208
209
}
209
210
210
- func newServiceAccount (t GinkgoTInterface , client operatorclient.ClientInterface , namespace , name string ) (sa * corev1.ServiceAccount , cleanup cleanupFunc ) {
211
+ func newServiceAccount (client operatorclient.ClientInterface , namespace , name string ) (sa * corev1.ServiceAccount , cleanup cleanupFunc ) {
211
212
request := & corev1.ServiceAccount {
212
213
ObjectMeta : metav1.ObjectMeta {
213
214
Namespace : namespace ,
@@ -216,18 +217,18 @@ func newServiceAccount(t GinkgoTInterface, client operatorclient.ClientInterface
216
217
}
217
218
218
219
sa , err := client .KubernetesInterface ().CoreV1 ().ServiceAccounts (namespace ).Create (context .TODO (), request , metav1.CreateOptions {})
219
- require . NoError ( t , err )
220
- require . NotNil ( t , sa )
220
+ Expect ( err ). ToNot ( HaveOccurred () )
221
+ Expect ( sa ). ToNot ( BeNil () )
221
222
222
223
cleanup = func () {
223
224
err := client .KubernetesInterface ().CoreV1 ().ServiceAccounts (sa .GetNamespace ()).Delete (context .TODO (), sa .GetName (), metav1.DeleteOptions {})
224
- require . NoError ( t , err )
225
+ Expect ( err ). ToNot ( HaveOccurred () )
225
226
}
226
227
227
228
return
228
229
}
229
230
230
- func newOperatorGroupWithServiceAccount (t GinkgoTInterface , client versioned.Interface , namespace , name , serviceAccountName string ) (og * v1.OperatorGroup , cleanup cleanupFunc ) {
231
+ func newOperatorGroupWithServiceAccount (client versioned.Interface , namespace , name , serviceAccountName string ) (og * v1.OperatorGroup , cleanup cleanupFunc ) {
231
232
request := & v1.OperatorGroup {
232
233
ObjectMeta : metav1.ObjectMeta {
233
234
Namespace : namespace ,
@@ -242,12 +243,12 @@ func newOperatorGroupWithServiceAccount(t GinkgoTInterface, client versioned.Int
242
243
}
243
244
244
245
og , err := client .OperatorsV1 ().OperatorGroups (namespace ).Create (context .TODO (), request , metav1.CreateOptions {})
245
- require . NoError ( t , err )
246
- require . NotNil ( t , og )
246
+ Expect ( err ). ToNot ( HaveOccurred () )
247
+ Expect ( og ). ToNot ( BeNil () )
247
248
248
249
cleanup = func () {
249
250
err := client .OperatorsV1 ().OperatorGroups (og .GetNamespace ()).Delete (context .TODO (), og .GetName (), metav1.DeleteOptions {})
250
- require . NoError ( t , err )
251
+ Expect ( err ). ToNot ( HaveOccurred () )
251
252
}
252
253
253
254
return
0 commit comments