mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
* Adds ExpressRoute circuit documentation * Adds tests and doc improvements * Code for basic Express Route Circuit support * Use the built-in validation helper * Added ignoreCaseDiffSuppressFunc to a few fields * Added more information to docs * Touchup * Moving SKU properties into a set. * Updates doc * A bit more tweaks * Switch to Sprintf for test string * Updating the acceptance test name for consistency
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package azurerm
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/Azure/azure-sdk-for-go/arm/network"
|
|
"github.com/hashicorp/errwrap"
|
|
)
|
|
|
|
func extractResourceGroupAndErcName(resourceId string) (resourceGroup string, name string, err error) {
|
|
id, err := parseAzureResourceID(resourceId)
|
|
|
|
if err != nil {
|
|
return "", "", err
|
|
}
|
|
resourceGroup = id.ResourceGroup
|
|
name = id.Path["expressRouteCircuits"]
|
|
|
|
return
|
|
}
|
|
|
|
func retrieveErcByResourceId(resourceId string, meta interface{}) (erc *network.ExpressRouteCircuit, resourceGroup string, e error) {
|
|
ercClient := meta.(*ArmClient).expressRouteCircuitClient
|
|
|
|
resGroup, name, err := extractResourceGroupAndErcName(resourceId)
|
|
if err != nil {
|
|
return nil, "", errwrap.Wrapf("Error Parsing Azure Resource ID - {{err}}", err)
|
|
}
|
|
|
|
resp, err := ercClient.Get(resGroup, name)
|
|
if err != nil {
|
|
if resp.StatusCode == http.StatusNotFound {
|
|
return nil, "", nil
|
|
}
|
|
return nil, "", errwrap.Wrapf(fmt.Sprintf("Error making Read request on Express Route Circuit %s: {{err}}", name), err)
|
|
}
|
|
|
|
return &resp, resGroup, nil
|
|
}
|