mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
fix: make azure disk URI case insensitive
This commit is contained in:
parent
81e6441d49
commit
4a37d04f52
@ -262,7 +262,7 @@ func (c *ManagedDiskController) ResizeDisk(diskURI string, oldSize resource.Quan
|
||||
// according to https://docs.microsoft.com/en-us/rest/api/compute/disks/get
|
||||
func getResourceGroupFromDiskURI(diskURI string) (string, error) {
|
||||
fields := strings.Split(diskURI, "/")
|
||||
if len(fields) != 9 || fields[3] != "resourceGroups" {
|
||||
if len(fields) != 9 || strings.ToLower(fields[3]) != "resourcegroups" {
|
||||
return "", fmt.Errorf("invalid disk URI: %s", diskURI)
|
||||
}
|
||||
return fields[4], nil
|
||||
|
@ -2705,6 +2705,12 @@ func TestGetResourceGroupFromDiskURI(t *testing.T) {
|
||||
expectedResult: "azure-k8s1102",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
// case insentive check
|
||||
diskURL: "/subscriptions/4be8920b-2978-43d7-axyz-04d8549c1d05/resourcegroups/azure-k8s1102/providers/Microsoft.Compute/disks/andy-mghyb1102-dynamic-pvc-f7f014c9-49f4-11e8-ab5c-000d3af7b38e",
|
||||
expectedResult: "azure-k8s1102",
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
diskURL: "/4be8920b-2978-43d7-axyz-04d8549c1d05/resourceGroups/azure-k8s1102/providers/Microsoft.Compute/disks/andy-mghyb1102-dynamic-pvc-f7f014c9-49f4-11e8-ab5c-000d3af7b38e",
|
||||
expectedResult: "",
|
||||
|
Loading…
Reference in New Issue
Block a user