@@ -80,7 +80,7 @@ func (cloud *FakeCloudProvider) GetDefaultZone() string {
80
80
return cloud .zone
81
81
}
82
82
83
- func (cloud * FakeCloudProvider ) RepairUnderspecifiedVolumeKey (ctx context.Context , volumeKey * meta.Key ) (* meta.Key , error ) {
83
+ func (cloud * FakeCloudProvider ) RepairUnderspecifiedVolumeKey (ctx context.Context , project string , volumeKey * meta.Key ) (* meta.Key , error ) {
84
84
switch volumeKey .Type () {
85
85
case meta .Zonal :
86
86
if volumeKey .Zone != common .UnspecifiedValue {
@@ -212,7 +212,7 @@ func (cloud *FakeCloudProvider) ListSnapshots(ctx context.Context, filter string
212
212
}
213
213
214
214
// Disk Methods
215
- func (cloud * FakeCloudProvider ) GetDisk (ctx context.Context , volKey * meta.Key , api GCEAPIVersion ) (* CloudDisk , error ) {
215
+ func (cloud * FakeCloudProvider ) GetDisk (ctx context.Context , project string , volKey * meta.Key , api GCEAPIVersion ) (* CloudDisk , error ) {
216
216
disk , ok := cloud .disks [volKey .Name ]
217
217
if ! ok {
218
218
return nil , notFoundError ()
@@ -249,7 +249,7 @@ func (cloud *FakeCloudProvider) ValidateExistingDisk(ctx context.Context, resp *
249
249
return ValidateDiskParameters (resp , params )
250
250
}
251
251
252
- func (cloud * FakeCloudProvider ) InsertDisk (ctx context.Context , volKey * meta.Key , params common.DiskParameters , capBytes int64 , capacityRange * csi.CapacityRange , replicaZones []string , snapshotID string , multiWriter bool ) error {
252
+ func (cloud * FakeCloudProvider ) InsertDisk (ctx context.Context , project string , volKey * meta.Key , params common.DiskParameters , capBytes int64 , capacityRange * csi.CapacityRange , replicaZones []string , snapshotID string , multiWriter bool ) error {
253
253
if disk , ok := cloud .disks [volKey .Name ]; ok {
254
254
err := cloud .ValidateExistingDisk (ctx , disk , params ,
255
255
int64 (capacityRange .GetRequiredBytes ()),
@@ -264,7 +264,7 @@ func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key
264
264
Name : volKey .Name ,
265
265
SizeGb : common .BytesToGbRoundUp (capBytes ),
266
266
Description : "Disk created by GCE-PD CSI Driver" ,
267
- Type : cloud .GetDiskTypeURI (volKey , params .DiskType ),
267
+ Type : cloud .GetDiskTypeURI (project , volKey , params .DiskType ),
268
268
SourceSnapshotId : snapshotID ,
269
269
Status : cloud .mockDiskStatus ,
270
270
Labels : params .Labels ,
@@ -277,10 +277,10 @@ func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key
277
277
switch volKey .Type () {
278
278
case meta .Zonal :
279
279
computeDisk .Zone = volKey .Zone
280
- computeDisk .SelfLink = fmt .Sprintf ("projects/%s/zones/%s/disks/%s" , cloud . project , volKey .Zone , volKey .Name )
280
+ computeDisk .SelfLink = fmt .Sprintf ("projects/%s/zones/%s/disks/%s" , project , volKey .Zone , volKey .Name )
281
281
case meta .Regional :
282
282
computeDisk .Region = volKey .Region
283
- computeDisk .SelfLink = fmt .Sprintf ("projects/%s/regions/%s/disks/%s" , cloud . project , volKey .Region , volKey .Name )
283
+ computeDisk .SelfLink = fmt .Sprintf ("projects/%s/regions/%s/disks/%s" , project , volKey .Region , volKey .Name )
284
284
default :
285
285
return fmt .Errorf ("could not create disk, key was neither zonal nor regional, instead got: %v" , volKey .String ())
286
286
}
@@ -289,16 +289,16 @@ func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key
289
289
return nil
290
290
}
291
291
292
- func (cloud * FakeCloudProvider ) DeleteDisk (ctx context.Context , volKey * meta.Key ) error {
292
+ func (cloud * FakeCloudProvider ) DeleteDisk (ctx context.Context , project string , volKey * meta.Key ) error {
293
293
if _ , ok := cloud .disks [volKey .Name ]; ! ok {
294
294
return notFoundError ()
295
295
}
296
296
delete (cloud .disks , volKey .Name )
297
297
return nil
298
298
}
299
299
300
- func (cloud * FakeCloudProvider ) AttachDisk (ctx context.Context , volKey * meta.Key , readWrite , diskType , instanceZone , instanceName string ) error {
301
- source := cloud .GetDiskSourceURI (volKey )
300
+ func (cloud * FakeCloudProvider ) AttachDisk (ctx context.Context , project string , volKey * meta.Key , readWrite , diskType , instanceZone , instanceName string ) error {
301
+ source := cloud .GetDiskSourceURI (project , volKey )
302
302
303
303
attachedDiskV1 := & computev1.AttachedDisk {
304
304
DeviceName : volKey .Name ,
@@ -315,7 +315,7 @@ func (cloud *FakeCloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key
315
315
return nil
316
316
}
317
317
318
- func (cloud * FakeCloudProvider ) DetachDisk (ctx context.Context , deviceName , instanceZone , instanceName string ) error {
318
+ func (cloud * FakeCloudProvider ) DetachDisk (ctx context.Context , project , deviceName , instanceZone , instanceName string ) error {
319
319
instance , ok := cloud .instances [instanceName ]
320
320
if ! ok {
321
321
return fmt .Errorf ("Failed to get instance %v" , instanceName )
@@ -332,31 +332,31 @@ func (cloud *FakeCloudProvider) DetachDisk(ctx context.Context, deviceName, inst
332
332
return nil
333
333
}
334
334
335
- func (cloud * FakeCloudProvider ) GetDiskTypeURI (volKey * meta.Key , diskType string ) string {
335
+ func (cloud * FakeCloudProvider ) GetDiskTypeURI (project string , volKey * meta.Key , diskType string ) string {
336
336
switch volKey .Type () {
337
337
case meta .Zonal :
338
- return cloud .getZonalDiskTypeURI (volKey .Zone , diskType )
338
+ return cloud .getZonalDiskTypeURI (project , volKey .Zone , diskType )
339
339
case meta .Regional :
340
- return cloud .getRegionalDiskTypeURI (volKey .Region , diskType )
340
+ return cloud .getRegionalDiskTypeURI (project , volKey .Region , diskType )
341
341
default :
342
342
return fmt .Sprintf ("could not get disk type uri, key was neither zonal nor regional, instead got: %v" , volKey .String ())
343
343
}
344
344
}
345
345
346
- func (cloud * FakeCloudProvider ) getZonalDiskTypeURI (zone , diskType string ) string {
347
- return fmt .Sprintf (diskTypeURITemplateSingleZone , cloud . project , zone , diskType )
346
+ func (cloud * FakeCloudProvider ) getZonalDiskTypeURI (project , zone , diskType string ) string {
347
+ return fmt .Sprintf (diskTypeURITemplateSingleZone , project , zone , diskType )
348
348
}
349
349
350
- func (cloud * FakeCloudProvider ) getRegionalDiskTypeURI (region , diskType string ) string {
351
- return fmt .Sprintf (diskTypeURITemplateRegional , cloud . project , region , diskType )
350
+ func (cloud * FakeCloudProvider ) getRegionalDiskTypeURI (project , region , diskType string ) string {
351
+ return fmt .Sprintf (diskTypeURITemplateRegional , project , region , diskType )
352
352
}
353
353
354
- func (cloud * FakeCloudProvider ) WaitForAttach (ctx context.Context , volKey * meta.Key , instanceZone , instanceName string ) error {
354
+ func (cloud * FakeCloudProvider ) WaitForAttach (ctx context.Context , project string , volKey * meta.Key , instanceZone , instanceName string ) error {
355
355
return nil
356
356
}
357
357
358
358
// Regional Disk Methods
359
- func (cloud * FakeCloudProvider ) GetReplicaZoneURI (zone string ) string {
359
+ func (cloud * FakeCloudProvider ) GetReplicaZoneURI (project , zone string ) string {
360
360
return ""
361
361
}
362
362
@@ -384,7 +384,7 @@ func (cloud *FakeCloudProvider) GetSnapshot(ctx context.Context, project, snapsh
384
384
return snapshot , nil
385
385
}
386
386
387
- func (cloud * FakeCloudProvider ) CreateSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
387
+ func (cloud * FakeCloudProvider ) CreateSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
388
388
if snapshot , ok := cloud .snapshots [snapshotName ]; ok {
389
389
return snapshot , nil
390
390
}
@@ -394,13 +394,13 @@ func (cloud *FakeCloudProvider) CreateSnapshot(ctx context.Context, volKey *meta
394
394
DiskSizeGb : int64 (DiskSizeGb ),
395
395
CreationTimestamp : Timestamp ,
396
396
Status : "UPLOADING" ,
397
- SelfLink : cloud .getGlobalSnapshotURI (snapshotName ),
397
+ SelfLink : cloud .getGlobalSnapshotURI (project , snapshotName ),
398
398
}
399
399
switch volKey .Type () {
400
400
case meta .Zonal :
401
- snapshotToCreate .SourceDisk = cloud .getZonalDiskSourceURI (volKey .Name , volKey .Zone )
401
+ snapshotToCreate .SourceDisk = cloud .getZonalDiskSourceURI (project , volKey .Name , volKey .Zone )
402
402
case meta .Regional :
403
- snapshotToCreate .SourceDisk = cloud .getRegionalDiskSourceURI (volKey .Name , volKey .Region )
403
+ snapshotToCreate .SourceDisk = cloud .getRegionalDiskSourceURI (project , volKey .Name , volKey .Region )
404
404
default :
405
405
return nil , fmt .Errorf ("could not create snapshot, disk key was neither zonal nor regional, instead got: %v" , volKey .String ())
406
406
}
@@ -409,7 +409,7 @@ func (cloud *FakeCloudProvider) CreateSnapshot(ctx context.Context, volKey *meta
409
409
return snapshotToCreate , nil
410
410
}
411
411
412
- func (cloud * FakeCloudProvider ) ResizeDisk (ctx context.Context , volKey * meta.Key , requestBytes int64 ) (int64 , error ) {
412
+ func (cloud * FakeCloudProvider ) ResizeDisk (ctx context.Context , project string , volKey * meta.Key , requestBytes int64 ) (int64 , error ) {
413
413
disk , ok := cloud .disks [volKey .Name ]
414
414
if ! ok {
415
415
return - 1 , notFoundError ()
@@ -424,7 +424,7 @@ func (cloud *FakeCloudProvider) ResizeDisk(ctx context.Context, volKey *meta.Key
424
424
}
425
425
426
426
// Snapshot Methods
427
- func (cloud * FakeCloudProvider ) DeleteSnapshot (ctx context.Context , snapshotName string ) error {
427
+ func (cloud * FakeCloudProvider ) DeleteSnapshot (ctx context.Context , project , snapshotName string ) error {
428
428
delete (cloud .snapshots , snapshotName )
429
429
return nil
430
430
}
@@ -434,7 +434,7 @@ func (cloud *FakeCloudProvider) ValidateExistingSnapshot(resp *computev1.Snapsho
434
434
return fmt .Errorf ("disk does not exist" )
435
435
}
436
436
437
- diskSource := cloud .GetDiskSourceURI (volKey )
437
+ diskSource := cloud .GetDiskSourceURI (cloud . project , volKey )
438
438
if resp .SourceDisk != diskSource {
439
439
return status .Error (codes .AlreadyExists , fmt .Sprintf ("snapshot already exists with same name but with a different disk source %s, expected disk source %s" , diskSource , resp .SourceDisk ))
440
440
}
@@ -443,37 +443,37 @@ func (cloud *FakeCloudProvider) ValidateExistingSnapshot(resp *computev1.Snapsho
443
443
return nil
444
444
}
445
445
446
- func (cloud * FakeCloudProvider ) GetDiskSourceURI (volKey * meta.Key ) string {
446
+ func (cloud * FakeCloudProvider ) GetDiskSourceURI (project string , volKey * meta.Key ) string {
447
447
switch volKey .Type () {
448
448
case meta .Zonal :
449
- return cloud .getZonalDiskSourceURI (volKey .Name , volKey .Zone )
449
+ return cloud .getZonalDiskSourceURI (project , volKey .Name , volKey .Zone )
450
450
case meta .Regional :
451
- return cloud .getRegionalDiskSourceURI (volKey .Name , volKey .Region )
451
+ return cloud .getRegionalDiskSourceURI (project , volKey .Name , volKey .Region )
452
452
default :
453
453
return ""
454
454
}
455
455
}
456
456
457
- func (cloud * FakeCloudProvider ) getZonalDiskSourceURI (diskName , zone string ) string {
457
+ func (cloud * FakeCloudProvider ) getZonalDiskSourceURI (project , diskName , zone string ) string {
458
458
return BasePath + fmt .Sprintf (
459
459
diskSourceURITemplateSingleZone ,
460
- cloud . project ,
460
+ project ,
461
461
zone ,
462
462
diskName )
463
463
}
464
464
465
- func (cloud * FakeCloudProvider ) getRegionalDiskSourceURI (diskName , region string ) string {
465
+ func (cloud * FakeCloudProvider ) getRegionalDiskSourceURI (project , diskName , region string ) string {
466
466
return BasePath + fmt .Sprintf (
467
467
diskSourceURITemplateRegional ,
468
- cloud . project ,
468
+ project ,
469
469
region ,
470
470
diskName )
471
471
}
472
472
473
- func (cloud * FakeCloudProvider ) getGlobalSnapshotURI (snapshotName string ) string {
473
+ func (cloud * FakeCloudProvider ) getGlobalSnapshotURI (project , snapshotName string ) string {
474
474
return BasePath + fmt .Sprintf (
475
475
snapshotURITemplateGlobal ,
476
- cloud . project ,
476
+ project ,
477
477
snapshotName )
478
478
}
479
479
@@ -490,11 +490,11 @@ type FakeBlockingCloudProvider struct {
490
490
// Upon starting a CreateSnapshot, it passes a chan 'executeCreateSnapshot' into readyToExecute, then blocks on executeCreateSnapshot.
491
491
// The test calling this function can block on readyToExecute to ensure that the operation has started and
492
492
// allowed the CreateSnapshot to continue by passing a struct into executeCreateSnapshot.
493
- func (cloud * FakeBlockingCloudProvider ) CreateSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
493
+ func (cloud * FakeBlockingCloudProvider ) CreateSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
494
494
executeCreateSnapshot := make (chan struct {})
495
495
cloud .ReadyToExecute <- executeCreateSnapshot
496
496
<- executeCreateSnapshot
497
- return cloud .FakeCloudProvider .CreateSnapshot (ctx , volKey , snapshotName )
497
+ return cloud .FakeCloudProvider .CreateSnapshot (ctx , project , volKey , snapshotName )
498
498
}
499
499
500
500
func notFoundError () * googleapi.Error {
0 commit comments