in types/azurerm_resource.go [207:249]
func ResourceTypeOfResourceId(input string) string {
if input == "/" {
return arm.TenantResourceType.String()
}
id := input
if resourceType, err := arm.ParseResourceType(id); err == nil {
if resourceType.Type != arm.ProviderResourceType.Type {
return resourceType.String()
}
}
idURL, err := url.ParseRequestURI(id)
if err != nil {
return ""
}
path := idURL.Path
path = strings.TrimPrefix(path, "/")
path = strings.TrimSuffix(path, "/")
components := strings.Split(path, "/")
resourceType := ""
provider := ""
for current := 0; current < len(components)-1; current += 2 {
key := components[current]
value := components[current+1]
// Check key/value for empty strings.
if key == "" || value == "" {
return ""
}
if key == "providers" {
provider = value
resourceType = provider
} else if len(provider) > 0 {
resourceType += "/" + key
}
}
return resourceType
}