mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-11 10:35:37 +00:00
Convert resource group name in Azure provider ID to lower cases
This commit is contained in:
@@ -37,7 +37,8 @@ var (
|
||||
nsgCacheTTL = 2 * time.Minute
|
||||
rtCacheTTL = 2 * time.Minute
|
||||
|
||||
azureNodeProviderIDRE = regexp.MustCompile(`^azure:///subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/(?:.*)`)
|
||||
azureNodeProviderIDRE = regexp.MustCompile(`^azure:///subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/(?:.*)`)
|
||||
azureResourceGroupNameRE = regexp.MustCompile(`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/(?:.*)`)
|
||||
)
|
||||
|
||||
// checkExistsFromError inspects an error and returns a true if err is nil,
|
||||
@@ -303,3 +304,14 @@ func (az *Cloud) IsNodeUnmanaged(nodeName string) (bool, error) {
|
||||
func (az *Cloud) IsNodeUnmanagedByProviderID(providerID string) bool {
|
||||
return !azureNodeProviderIDRE.Match([]byte(providerID))
|
||||
}
|
||||
|
||||
// convertResourceGroupNameToLower converts the resource group name in the resource ID to be lowered.
|
||||
func convertResourceGroupNameToLower(resourceID string) (string, error) {
|
||||
matches := azureResourceGroupNameRE.FindStringSubmatch(resourceID)
|
||||
if len(matches) != 2 {
|
||||
return "", fmt.Errorf("%q isn't in Azure resource ID format %q", resourceID, azureResourceGroupNameRE.String())
|
||||
}
|
||||
|
||||
resourceGroup := matches[1]
|
||||
return strings.Replace(resourceID, resourceGroup, strings.ToLower(resourceGroup), 1), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user