Merge pull request #4739 from hashicorp/b-azurerm-resource-id-parsing
provider/azurerm: Parse "resourcegroups" in IDs
This commit is contained in:
commit
a4abb0e66c
|
@ -69,7 +69,15 @@ func parseAzureResourceID(id string) (*ResourceID, error) {
|
||||||
idObj.ResourceGroup = resourceGroup
|
idObj.ResourceGroup = resourceGroup
|
||||||
delete(componentMap, "resourceGroups")
|
delete(componentMap, "resourceGroups")
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("No resource group name found in: %q", path)
|
// Some Azure APIs are weird and provide things in lower case...
|
||||||
|
// However it's not clear whether the casing of other elements in the URI
|
||||||
|
// matter, so we explicitly look for that case here.
|
||||||
|
if resourceGroup, ok := componentMap["resourcegroups"]; ok {
|
||||||
|
idObj.ResourceGroup = resourceGroup
|
||||||
|
delete(componentMap, "resourcegroups")
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("No resource group name found in: %q", path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is OK not to have a provider in the case of a resource group
|
// It is OK not to have a provider in the case of a resource group
|
||||||
|
|
|
@ -89,6 +89,18 @@ func TestParseAzureResourceID(t *testing.T) {
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"/subscriptions/34ca515c-4629-458e-bf7c-738d77e0d0ea/resourcegroups/acceptanceTestResourceGroup1/providers/Microsoft.Cdn/profiles/acceptanceTestCdnProfile1",
|
||||||
|
&ResourceID{
|
||||||
|
SubscriptionID: "34ca515c-4629-458e-bf7c-738d77e0d0ea",
|
||||||
|
ResourceGroup: "acceptanceTestResourceGroup1",
|
||||||
|
Provider: "Microsoft.Cdn",
|
||||||
|
Path: map[string]string{
|
||||||
|
"profiles": "acceptanceTestCdnProfile1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
|
|
Loading…
Reference in New Issue