Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed requiresImport test case * Progress exposing dns zone groups * Work thus far redesign * Progress thus far * Progress * Change data structure * Close mostly working now * Remove old resources * Code complete needs docs and tests * Add docs and example * Added Tests and updated docs * Fix Lint Errors * Update azurerm/internal/services/network/parse/private_endpoint.go Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com> * Update azurerm/internal/services/network/private_endpoint_resource.go Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com> * Update azurerm/internal/services/network/private_endpoint_resource.go Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com> * Changes per PR * Fix lint error * Requested changes per PR comment Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>
- Loading branch information
1 parent
1a7f16d
commit ce3eb26
Showing
11 changed files
with
1,131 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
azurerm/internal/services/network/parse/private_endpoint.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package parse | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" | ||
) | ||
|
||
type NameResourceGroup struct { | ||
ResourceGroup string | ||
Name string | ||
ID string | ||
} | ||
|
||
func PrivateDnsZoneGroupResourceID(input string) (*NameResourceGroup, error) { | ||
if len(strings.TrimSpace(input)) == 0 { | ||
return nil, fmt.Errorf("unable to parse Private DNS Zone Group ID %q: input is empty", input) | ||
} | ||
|
||
id, err := azure.ParseAzureResourceID(input) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to parse Private DNS Zone Group ID %q: %+v", input, err) | ||
} | ||
|
||
privateDnsZoneGroup := NameResourceGroup{ | ||
ResourceGroup: id.ResourceGroup, | ||
} | ||
|
||
if privateDnsZoneGroup.Name, err = id.PopSegment("privateDnsZoneGroups"); err != nil { | ||
return nil, err | ||
} | ||
|
||
if privateDnsZoneGroup.ID = input; err != nil { | ||
return nil, err | ||
} | ||
|
||
return &privateDnsZoneGroup, nil | ||
} | ||
|
||
func PrivateDnsZoneResourceIDs(input []interface{}) (*[]NameResourceGroup, error) { | ||
results := make([]NameResourceGroup, 0) | ||
|
||
for _, item := range input { | ||
v := item.(string) | ||
|
||
if privateDnsZone, err := PrivateDnsZoneResourceID(v); err != nil { | ||
return nil, fmt.Errorf("unable to parse Private DNS Zone ID %q: %+v", v, err) | ||
} else { | ||
results = append(results, *privateDnsZone) | ||
} | ||
} | ||
|
||
return &results, nil | ||
} | ||
|
||
func PrivateDnsZoneResourceID(input string) (*NameResourceGroup, error) { | ||
if len(strings.TrimSpace(input)) == 0 { | ||
return nil, fmt.Errorf("unable to parse Private DNS Zone ID %q: input is empty", input) | ||
} | ||
|
||
id, err := azure.ParseAzureResourceID(input) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to parse Private DNS Zone ID %q: %+v", input, err) | ||
} | ||
|
||
privateDnsZone := NameResourceGroup{ | ||
ResourceGroup: id.ResourceGroup, | ||
} | ||
|
||
if privateDnsZone.Name, err = id.PopSegment("privateDnsZones"); err != nil { | ||
return nil, err | ||
} | ||
|
||
if privateDnsZone.ID = input; err != nil { | ||
return nil, err | ||
} | ||
|
||
return &privateDnsZone, nil | ||
} | ||
|
||
func PrivateEndpointResourceID(input string) (*NameResourceGroup, error) { | ||
id, err := azure.ParseAzureResourceID(input) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to parse Private Endpoint ID %q: %+v", input, err) | ||
} | ||
|
||
privateEndpoint := NameResourceGroup{ | ||
ResourceGroup: id.ResourceGroup, | ||
} | ||
|
||
if privateEndpoint.Name, err = id.PopSegment("privateEndpoints"); err != nil { | ||
return nil, err | ||
} | ||
|
||
if privateEndpoint.ID = input; err != nil { | ||
return nil, err | ||
} | ||
|
||
return &privateEndpoint, nil | ||
} | ||
|
||
func ValidatePrivateDnsZoneResourceID(i interface{}, k string) (warnings []string, errors []error) { | ||
v, ok := i.(string) | ||
if !ok { | ||
errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) | ||
return | ||
} | ||
|
||
if id, err := azure.ParseAzureResourceID(v); err != nil { | ||
errors = append(errors, fmt.Errorf("Can not parse %q as a resource id: %v", k, err)) | ||
} else if _, err = id.PopSegment("privateDnsZones"); err != nil { | ||
errors = append(errors, fmt.Errorf("Can not parse %q as a private dns zone resource id: %v", k, err)) | ||
} | ||
|
||
return warnings, errors | ||
} |
Oops, something went wrong.