@@ -28,6 +28,7 @@ import (
28
28
osspec "github.com/kubernetes-sigs/container-object-storage-interface-spec"
29
29
fakespec "github.com/kubernetes-sigs/container-object-storage-interface-spec/fake"
30
30
31
+ corev1 "k8s.io/api/core/v1"
31
32
v1 "k8s.io/api/core/v1"
32
33
33
34
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -118,6 +119,8 @@ func TestAdd(t *testing.T) {
118
119
generatedPrincipal := "driverPrincipal"
119
120
sa := "serviceAccount"
120
121
mpc := struct { fakespec.MockProvisionerClient }{}
122
+ extraParamName := "ParamName"
123
+ extraParamValue := "ParamValue"
121
124
122
125
testCases := []struct {
123
126
name string
@@ -126,6 +129,7 @@ func TestAdd(t *testing.T) {
126
129
grantFunc func (ctx context.Context , in * osspec.ProvisionerGrantBucketAccessRequest , opts ... grpc.CallOption ) (* osspec.ProvisionerGrantBucketAccessResponse , error )
127
130
principal string
128
131
serviceAccount string
132
+ params map [string ]string
129
133
}{
130
134
{
131
135
name : "S3" ,
@@ -158,6 +162,9 @@ func TestAdd(t *testing.T) {
158
162
if in .BucketContext ["Endpoint" ] != endpoint {
159
163
t .Errorf ("expected %s, got %s" , endpoint , in .BucketContext ["Endpoint" ])
160
164
}
165
+ if in .BucketContext [extraParamName ] != extraParamValue {
166
+ t .Errorf ("expected %s, got %s" , extraParamValue , in .BucketContext [extraParamName ])
167
+ }
161
168
return & osspec.ProvisionerGrantBucketAccessResponse {
162
169
Principal : principal ,
163
170
CredentialsFileContents : credsContents ,
@@ -166,6 +173,9 @@ func TestAdd(t *testing.T) {
166
173
},
167
174
principal : principal ,
168
175
serviceAccount : "" ,
176
+ params : map [string ]string {
177
+ extraParamName : extraParamValue ,
178
+ },
169
179
},
170
180
{
171
181
name : "GCS" ,
@@ -194,6 +204,9 @@ func TestAdd(t *testing.T) {
194
204
if in .BucketContext ["ProjectID" ] != projID {
195
205
t .Errorf ("expected %s, got %s" , projID , in .BucketContext ["ProjectID" ])
196
206
}
207
+ if in .BucketContext [extraParamName ] != extraParamValue {
208
+ t .Errorf ("expected %s, got %s" , extraParamValue , in .BucketContext [extraParamName ])
209
+ }
197
210
return & osspec.ProvisionerGrantBucketAccessResponse {
198
211
Principal : principal ,
199
212
CredentialsFileContents : credsContents ,
@@ -202,6 +215,9 @@ func TestAdd(t *testing.T) {
202
215
},
203
216
principal : principal ,
204
217
serviceAccount : "" ,
218
+ params : map [string ]string {
219
+ extraParamName : extraParamValue ,
220
+ },
205
221
},
206
222
{
207
223
name : "AzureBlob" ,
@@ -222,6 +238,9 @@ func TestAdd(t *testing.T) {
222
238
if in .BucketContext ["StorageAccount" ] != account {
223
239
t .Errorf ("expected %s, got %s" , account , in .BucketContext ["StorageAccount" ])
224
240
}
241
+ if in .BucketContext [extraParamName ] != extraParamValue {
242
+ t .Errorf ("expected %s, got %s" , extraParamValue , in .BucketContext [extraParamName ])
243
+ }
225
244
return & osspec.ProvisionerGrantBucketAccessResponse {
226
245
Principal : principal ,
227
246
CredentialsFileContents : credsContents ,
@@ -230,6 +249,9 @@ func TestAdd(t *testing.T) {
230
249
},
231
250
principal : principal ,
232
251
serviceAccount : "" ,
252
+ params : map [string ]string {
253
+ extraParamName : extraParamValue ,
254
+ },
233
255
},
234
256
{
235
257
name : "No Principal" ,
@@ -252,6 +274,9 @@ func TestAdd(t *testing.T) {
252
274
},
253
275
principal : "" ,
254
276
serviceAccount : "" ,
277
+ params : map [string ]string {
278
+ extraParamName : extraParamValue ,
279
+ },
255
280
},
256
281
{
257
282
name : "ServiceAccount exists" ,
@@ -274,6 +299,9 @@ func TestAdd(t *testing.T) {
274
299
},
275
300
principal : principal ,
276
301
serviceAccount : sa ,
302
+ params : map [string ]string {
303
+ extraParamName : extraParamValue ,
304
+ },
277
305
},
278
306
}
279
307
@@ -297,10 +325,16 @@ func TestAdd(t *testing.T) {
297
325
BucketInstanceName : instanceName ,
298
326
Provisioner : provisioner ,
299
327
Principal : tc .principal ,
300
- ServiceAccount : tc .serviceAccount ,
328
+ Parameters : tc .params ,
301
329
},
302
330
}
303
331
332
+ if len (tc .serviceAccount ) > 0 {
333
+ ba .Spec .ServiceAccount = & corev1.ObjectReference {
334
+ Name : tc .serviceAccount ,
335
+ }
336
+ }
337
+
304
338
ctx := context .TODO ()
305
339
tc .setProtocol (& b )
306
340
client := fakebucketclientset .NewSimpleClientset (& ba , & b )
@@ -383,13 +417,16 @@ func TestDelete(t *testing.T) {
383
417
endpoint := "endpoint1"
384
418
instanceName := "instance"
385
419
mpc := struct { fakespec.MockProvisionerClient }{}
420
+ extraParamName := "ParamName"
421
+ extraParamValue := "ParamValue"
386
422
387
423
testCases := []struct {
388
424
name string
389
425
setProtocol func (b * v1alpha1.Bucket )
390
426
protocolName v1alpha1.ProtocolName
391
427
revokeFunc func (ctx context.Context , in * osspec.ProvisionerRevokeBucketAccessRequest , opts ... grpc.CallOption ) (* osspec.ProvisionerRevokeBucketAccessResponse , error )
392
428
serviceAccount string
429
+ params map [string ]string
393
430
}{
394
431
{
395
432
name : "S3" ,
@@ -422,9 +459,15 @@ func TestDelete(t *testing.T) {
422
459
if in .BucketContext ["Endpoint" ] != endpoint {
423
460
t .Errorf ("expected %s, got %s" , endpoint , in .BucketContext ["Endpoint" ])
424
461
}
462
+ if in .BucketContext [extraParamName ] != extraParamValue {
463
+ t .Errorf ("expected %s, got %s" , extraParamValue , in .BucketContext [extraParamName ])
464
+ }
425
465
return & osspec.ProvisionerRevokeBucketAccessResponse {}, nil
426
466
},
427
467
serviceAccount : "" ,
468
+ params : map [string ]string {
469
+ extraParamName : extraParamValue ,
470
+ },
428
471
},
429
472
{
430
473
name : "GCS" ,
@@ -453,9 +496,15 @@ func TestDelete(t *testing.T) {
453
496
if in .BucketContext ["ProjectID" ] != projID {
454
497
t .Errorf ("expected %s, got %s" , projID , in .BucketContext ["ProjectID" ])
455
498
}
499
+ if in .BucketContext [extraParamName ] != extraParamValue {
500
+ t .Errorf ("expected %s, got %s" , extraParamValue , in .BucketContext [extraParamName ])
501
+ }
456
502
return & osspec.ProvisionerRevokeBucketAccessResponse {}, nil
457
503
},
458
504
serviceAccount : "" ,
505
+ params : map [string ]string {
506
+ extraParamName : extraParamValue ,
507
+ },
459
508
},
460
509
{
461
510
name : "AzureBlob" ,
@@ -476,9 +525,15 @@ func TestDelete(t *testing.T) {
476
525
if in .BucketContext ["StorageAccount" ] != account {
477
526
t .Errorf ("expected %s, got %s" , account , in .BucketContext ["StorageAccount" ])
478
527
}
528
+ if in .BucketContext [extraParamName ] != extraParamValue {
529
+ t .Errorf ("expected %s, got %s" , extraParamValue , in .BucketContext [extraParamName ])
530
+ }
479
531
return & osspec.ProvisionerRevokeBucketAccessResponse {}, nil
480
532
},
481
533
serviceAccount : "" ,
534
+ params : map [string ]string {
535
+ extraParamName : extraParamValue ,
536
+ },
482
537
},
483
538
{
484
539
name : "service account exists" ,
@@ -511,9 +566,15 @@ func TestDelete(t *testing.T) {
511
566
if in .BucketContext ["Endpoint" ] != endpoint {
512
567
t .Errorf ("expected %s, got %s" , endpoint , in .BucketContext ["Endpoint" ])
513
568
}
569
+ if in .BucketContext [extraParamName ] != extraParamValue {
570
+ t .Errorf ("expected %s, got %s" , extraParamValue , in .BucketContext [extraParamName ])
571
+ }
514
572
return & osspec.ProvisionerRevokeBucketAccessResponse {}, nil
515
573
},
516
574
serviceAccount : "serviceAccount" ,
575
+ params : map [string ]string {
576
+ extraParamName : extraParamValue ,
577
+ },
517
578
},
518
579
}
519
580
@@ -537,12 +598,18 @@ func TestDelete(t *testing.T) {
537
598
BucketInstanceName : instanceName ,
538
599
Provisioner : provisioner ,
539
600
Principal : principal ,
540
- ServiceAccount : tc .serviceAccount ,
601
+ Parameters : tc .params ,
541
602
},
542
603
Status : v1alpha1.BucketAccessStatus {
543
604
AccessGranted : true ,
544
605
},
545
606
}
607
+
608
+ if len (tc .serviceAccount ) > 0 {
609
+ ba .Spec .ServiceAccount = & corev1.ObjectReference {
610
+ Name : tc .serviceAccount ,
611
+ }
612
+ }
546
613
secretName := generateSecretName (ba .UID )
547
614
secret := v1.Secret {
548
615
ObjectMeta : metav1.ObjectMeta {
0 commit comments