New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_private_endpoint
- expose private_dns_zone_group
, private_dns_zone_configs
, and custom_dns_configs
#7246
Merged
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4f44dda
Fixed requiresImport test case
WodansSon 6a4ae70
Progress exposing dns zone groups
WodansSon 8631c09
Work thus far redesign
WodansSon a4db18c
Progress thus far
WodansSon 806d32f
Progress
WodansSon afdf68d
Change data structure
WodansSon af3b826
Close mostly working now
WodansSon 6379995
Remove old resources
WodansSon 00b7771
Code complete needs docs and tests
WodansSon 15eaab3
Add docs and example
WodansSon 28b8890
Added Tests and updated docs
WodansSon 20ecd20
Fix Lint Errors
WodansSon 208d980
Update azurerm/internal/services/network/parse/private_endpoint.go
WodansSon 1f1b8b9
Update azurerm/internal/services/network/private_endpoint_resource.go
WodansSon 072f4c5
Update azurerm/internal/services/network/private_endpoint_resource.go
WodansSon bf453a6
Changes per PR
WodansSon bc9751d
Fix lint error
WodansSon fe072dc
Requested changes per PR comment
WodansSon File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use the
PopSegment
andValidateNoEmptySegments
functions here to ensure this is the ID of a private endpoint and not something elseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly Fixed. I can't use
ValidateNoEmptySegments
because I am parsing the information for multiple resources from one resource ID(e.g. /subscriptions/XXXX/resourceGroups/jcline-privateDns-rg
/providers/Microsoft.Network/privateEndpoints/contoso-cosmosdb
/privateDnsZoneGroups/privatelink.postgres.database.azure.com2
/privateDnsZoneConfigs/finance-contoso-com
.