@@ -80,7 +80,7 @@ func (cloud *FakeCloudProvider) GetDefaultZone() string {
8080 return cloud .zone
8181}
8282
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 ) {
8484 switch volumeKey .Type () {
8585 case meta .Zonal :
8686 if volumeKey .Zone != common .UnspecifiedValue {
@@ -212,7 +212,7 @@ func (cloud *FakeCloudProvider) ListSnapshots(ctx context.Context, filter string
212212}
213213
214214// 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 ) {
216216 disk , ok := cloud .disks [volKey .Name ]
217217 if ! ok {
218218 return nil , notFoundError ()
@@ -249,7 +249,7 @@ func (cloud *FakeCloudProvider) ValidateExistingDisk(ctx context.Context, resp *
249249 return ValidateDiskParameters (resp , params )
250250}
251251
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 {
253253 if disk , ok := cloud .disks [volKey .Name ]; ok {
254254 err := cloud .ValidateExistingDisk (ctx , disk , params ,
255255 int64 (capacityRange .GetRequiredBytes ()),
@@ -264,7 +264,7 @@ func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key
264264 Name : volKey .Name ,
265265 SizeGb : common .BytesToGbRoundUp (capBytes ),
266266 Description : "Disk created by GCE-PD CSI Driver" ,
267- Type : cloud .GetDiskTypeURI (volKey , params .DiskType ),
267+ Type : cloud .GetDiskTypeURI (project , volKey , params .DiskType ),
268268 SourceSnapshotId : snapshotID ,
269269 Status : cloud .mockDiskStatus ,
270270 Labels : params .Labels ,
@@ -277,10 +277,10 @@ func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key
277277 switch volKey .Type () {
278278 case meta .Zonal :
279279 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 )
281281 case meta .Regional :
282282 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 )
284284 default :
285285 return fmt .Errorf ("could not create disk, key was neither zonal nor regional, instead got: %v" , volKey .String ())
286286 }
@@ -289,16 +289,16 @@ func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key
289289 return nil
290290}
291291
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 {
293293 if _ , ok := cloud .disks [volKey .Name ]; ! ok {
294294 return notFoundError ()
295295 }
296296 delete (cloud .disks , volKey .Name )
297297 return nil
298298}
299299
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 )
302302
303303 attachedDiskV1 := & computev1.AttachedDisk {
304304 DeviceName : volKey .Name ,
@@ -315,7 +315,7 @@ func (cloud *FakeCloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key
315315 return nil
316316}
317317
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 {
319319 instance , ok := cloud .instances [instanceName ]
320320 if ! ok {
321321 return fmt .Errorf ("Failed to get instance %v" , instanceName )
@@ -332,31 +332,31 @@ func (cloud *FakeCloudProvider) DetachDisk(ctx context.Context, deviceName, inst
332332 return nil
333333}
334334
335- func (cloud * FakeCloudProvider ) GetDiskTypeURI (volKey * meta.Key , diskType string ) string {
335+ func (cloud * FakeCloudProvider ) GetDiskTypeURI (project string , volKey * meta.Key , diskType string ) string {
336336 switch volKey .Type () {
337337 case meta .Zonal :
338- return cloud .getZonalDiskTypeURI (volKey .Zone , diskType )
338+ return cloud .getZonalDiskTypeURI (project , volKey .Zone , diskType )
339339 case meta .Regional :
340- return cloud .getRegionalDiskTypeURI (volKey .Region , diskType )
340+ return cloud .getRegionalDiskTypeURI (project , volKey .Region , diskType )
341341 default :
342342 return fmt .Sprintf ("could not get disk type uri, key was neither zonal nor regional, instead got: %v" , volKey .String ())
343343 }
344344}
345345
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 )
348348}
349349
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 )
352352}
353353
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 {
355355 return nil
356356}
357357
358358// Regional Disk Methods
359- func (cloud * FakeCloudProvider ) GetReplicaZoneURI (zone string ) string {
359+ func (cloud * FakeCloudProvider ) GetReplicaZoneURI (project , zone string ) string {
360360 return ""
361361}
362362
@@ -384,7 +384,7 @@ func (cloud *FakeCloudProvider) GetSnapshot(ctx context.Context, project, snapsh
384384 return snapshot , nil
385385}
386386
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 ) {
388388 if snapshot , ok := cloud .snapshots [snapshotName ]; ok {
389389 return snapshot , nil
390390 }
@@ -394,13 +394,13 @@ func (cloud *FakeCloudProvider) CreateSnapshot(ctx context.Context, volKey *meta
394394 DiskSizeGb : int64 (DiskSizeGb ),
395395 CreationTimestamp : Timestamp ,
396396 Status : "UPLOADING" ,
397- SelfLink : cloud .getGlobalSnapshotURI (snapshotName ),
397+ SelfLink : cloud .getGlobalSnapshotURI (project , snapshotName ),
398398 }
399399 switch volKey .Type () {
400400 case meta .Zonal :
401- snapshotToCreate .SourceDisk = cloud .getZonalDiskSourceURI (volKey .Name , volKey .Zone )
401+ snapshotToCreate .SourceDisk = cloud .getZonalDiskSourceURI (project , volKey .Name , volKey .Zone )
402402 case meta .Regional :
403- snapshotToCreate .SourceDisk = cloud .getRegionalDiskSourceURI (volKey .Name , volKey .Region )
403+ snapshotToCreate .SourceDisk = cloud .getRegionalDiskSourceURI (project , volKey .Name , volKey .Region )
404404 default :
405405 return nil , fmt .Errorf ("could not create snapshot, disk key was neither zonal nor regional, instead got: %v" , volKey .String ())
406406 }
@@ -409,7 +409,7 @@ func (cloud *FakeCloudProvider) CreateSnapshot(ctx context.Context, volKey *meta
409409 return snapshotToCreate , nil
410410}
411411
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 ) {
413413 disk , ok := cloud .disks [volKey .Name ]
414414 if ! ok {
415415 return - 1 , notFoundError ()
@@ -424,7 +424,7 @@ func (cloud *FakeCloudProvider) ResizeDisk(ctx context.Context, volKey *meta.Key
424424}
425425
426426// 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 {
428428 delete (cloud .snapshots , snapshotName )
429429 return nil
430430}
@@ -434,7 +434,7 @@ func (cloud *FakeCloudProvider) ValidateExistingSnapshot(resp *computev1.Snapsho
434434 return fmt .Errorf ("disk does not exist" )
435435 }
436436
437- diskSource := cloud .GetDiskSourceURI (volKey )
437+ diskSource := cloud .GetDiskSourceURI (cloud . project , volKey )
438438 if resp .SourceDisk != diskSource {
439439 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 ))
440440 }
@@ -443,37 +443,37 @@ func (cloud *FakeCloudProvider) ValidateExistingSnapshot(resp *computev1.Snapsho
443443 return nil
444444}
445445
446- func (cloud * FakeCloudProvider ) GetDiskSourceURI (volKey * meta.Key ) string {
446+ func (cloud * FakeCloudProvider ) GetDiskSourceURI (project string , volKey * meta.Key ) string {
447447 switch volKey .Type () {
448448 case meta .Zonal :
449- return cloud .getZonalDiskSourceURI (volKey .Name , volKey .Zone )
449+ return cloud .getZonalDiskSourceURI (project , volKey .Name , volKey .Zone )
450450 case meta .Regional :
451- return cloud .getRegionalDiskSourceURI (volKey .Name , volKey .Region )
451+ return cloud .getRegionalDiskSourceURI (project , volKey .Name , volKey .Region )
452452 default :
453453 return ""
454454 }
455455}
456456
457- func (cloud * FakeCloudProvider ) getZonalDiskSourceURI (diskName , zone string ) string {
457+ func (cloud * FakeCloudProvider ) getZonalDiskSourceURI (project , diskName , zone string ) string {
458458 return BasePath + fmt .Sprintf (
459459 diskSourceURITemplateSingleZone ,
460- cloud . project ,
460+ project ,
461461 zone ,
462462 diskName )
463463}
464464
465- func (cloud * FakeCloudProvider ) getRegionalDiskSourceURI (diskName , region string ) string {
465+ func (cloud * FakeCloudProvider ) getRegionalDiskSourceURI (project , diskName , region string ) string {
466466 return BasePath + fmt .Sprintf (
467467 diskSourceURITemplateRegional ,
468- cloud . project ,
468+ project ,
469469 region ,
470470 diskName )
471471}
472472
473- func (cloud * FakeCloudProvider ) getGlobalSnapshotURI (snapshotName string ) string {
473+ func (cloud * FakeCloudProvider ) getGlobalSnapshotURI (project , snapshotName string ) string {
474474 return BasePath + fmt .Sprintf (
475475 snapshotURITemplateGlobal ,
476- cloud . project ,
476+ project ,
477477 snapshotName )
478478}
479479
@@ -490,11 +490,11 @@ type FakeBlockingCloudProvider struct {
490490// Upon starting a CreateSnapshot, it passes a chan 'executeCreateSnapshot' into readyToExecute, then blocks on executeCreateSnapshot.
491491// The test calling this function can block on readyToExecute to ensure that the operation has started and
492492// 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 ) {
494494 executeCreateSnapshot := make (chan struct {})
495495 cloud .ReadyToExecute <- executeCreateSnapshot
496496 <- executeCreateSnapshot
497- return cloud .FakeCloudProvider .CreateSnapshot (ctx , volKey , snapshotName )
497+ return cloud .FakeCloudProvider .CreateSnapshot (ctx , project , volKey , snapshotName )
498498}
499499
500500func notFoundError () * googleapi.Error {
0 commit comments