Skip to content

Commit 790db85

Browse files
committed
fix: volumeID is incorrent when project name contains alpha/beta/v1
1 parent d14b457 commit 790db85

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/gce-pd-csi-driver/controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ func generateCreateVolumeResponse(disk *gce.CloudDisk, zones []string, params co
17451745
}
17461746

17471747
func cleanSelfLink(selfLink string) string {
1748-
r, _ := regexp.Compile("https:\\/\\/www.*apis.com\\/.*(v1|beta|alpha)\\/")
1748+
r, _ := regexp.Compile(`https://www.*apis.com/.*?(v1|beta|alpha)/`)
17491749
return r.ReplaceAllString(selfLink, "")
17501750
}
17511751

pkg/gce-pd-csi-driver/controller_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,11 @@ func TestCleanSelfLink(t *testing.T) {
33043304
in: "https://www.partnerapis.com/compute/alpha/projects/project/zones/zone/disks/disk",
33053305
want: "projects/project/zones/zone/disks/disk",
33063306
},
3307+
{
3308+
name: "project name contains keyword",
3309+
in: "https://www.partnerapis.com/compute/alpha/projects/proj-alpha/zones/zone/disks/disk",
3310+
want: "projects/proj-alpha/zones/zone/disks/disk",
3311+
},
33073312
}
33083313

33093314
for _, tc := range testCases {

0 commit comments

Comments
 (0)