Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .teamcity/components/generated/services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var services = mapOf(
"servicefabric" to "Service Fabric",
"servicefabricmanaged" to "Service Fabric Managed Clusters",
"servicebus" to "ServiceBus",
"serviceconnector" to "ServiceConnector",
"signalr" to "SignalR",
"springcloud" to "Spring Cloud",
"storage" to "Storage",
Expand Down
3 changes: 3 additions & 0 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import (
securityCenter "github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter/client"
sentinel "github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel/client"
serviceBus "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/client"
serviceConnector "github.com/hashicorp/terraform-provider-azurerm/internal/services/serviceconnector/client"
serviceFabric "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicefabric/client"
serviceFabricManaged "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicefabricmanaged/client"
signalr "github.com/hashicorp/terraform-provider-azurerm/internal/services/signalr/client"
Expand Down Expand Up @@ -206,6 +207,7 @@ type Client struct {
SecurityCenter *securityCenter.Client
Sentinel *sentinel.Client
ServiceBus *serviceBus.Client
ServiceConnector *serviceConnector.Client
ServiceFabric *serviceFabric.Client
ServiceFabricManaged *serviceFabricManaged.Client
SignalR *signalr.Client
Expand Down Expand Up @@ -319,6 +321,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
client.SecurityCenter = securityCenter.NewClient(o)
client.Sentinel = sentinel.NewClient(o)
client.ServiceBus = serviceBus.NewClient(o)
client.ServiceConnector = serviceConnector.NewClient(o)
client.ServiceFabric = serviceFabric.NewClient(o)
client.ServiceFabricManaged = serviceFabricManaged.NewClient(o)
client.SignalR = signalr.NewClient(o)
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/serviceconnector"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/servicefabric"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/servicefabricmanaged"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/signalr"
Expand Down Expand Up @@ -128,6 +129,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
policy.Registration{},
resource.Registration{},
sentinel.Registration{},
serviceconnector.Registration{},
servicefabricmanaged.Registration{},
streamanalytics.Registration{},
web.Registration{},
Expand Down
75 changes: 75 additions & 0 deletions internal/services/privatedns/parse/a_record.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package parse

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import (
"fmt"
"strings"

"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
)

type ARecordId struct {
SubscriptionId string
ResourceGroup string
PrivateDnsZoneName string
AName string
}

func NewARecordID(subscriptionId, resourceGroup, privateDnsZoneName, aName string) ARecordId {
return ARecordId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
PrivateDnsZoneName: privateDnsZoneName,
AName: aName,
}
}

func (id ARecordId) String() string {
segments := []string{
fmt.Sprintf("A Name %q", id.AName),
fmt.Sprintf("Private Dns Zone Name %q", id.PrivateDnsZoneName),
fmt.Sprintf("Resource Group %q", id.ResourceGroup),
}
segmentsStr := strings.Join(segments, " / ")
return fmt.Sprintf("%s: (%s)", "A Record", segmentsStr)
}

func (id ARecordId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateDnsZones/%s/A/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.PrivateDnsZoneName, id.AName)
}

// ARecordID parses a ARecord ID into an ARecordId struct
func ARecordID(input string) (*ARecordId, error) {
id, err := resourceids.ParseAzureResourceID(input)
if err != nil {
return nil, err
}

resourceId := ARecordId{
SubscriptionId: id.SubscriptionID,
ResourceGroup: id.ResourceGroup,
}

if resourceId.SubscriptionId == "" {
return nil, fmt.Errorf("ID was missing the 'subscriptions' element")
}

if resourceId.ResourceGroup == "" {
return nil, fmt.Errorf("ID was missing the 'resourceGroups' element")
}

if resourceId.PrivateDnsZoneName, err = id.PopSegment("privateDnsZones"); err != nil {
return nil, err
}
if resourceId.AName, err = id.PopSegment("A"); err != nil {
return nil, err
}

if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, err
}

return &resourceId, nil
}
128 changes: 128 additions & 0 deletions internal/services/privatedns/parse/a_record_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package parse

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import (
"testing"

"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
)

var _ resourceids.Id = ARecordId{}

func TestARecordIDFormatter(t *testing.T) {
actual := NewARecordID("12345678-1234-9876-4563-123456789012", "resGroup1", "privateDnsZone1", "eh1").ID()
expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateDnsZones/privateDnsZone1/A/eh1"
if actual != expected {
t.Fatalf("Expected %q but got %q", expected, actual)
}
}

func TestARecordID(t *testing.T) {
testData := []struct {
Input string
Error bool
Expected *ARecordId
}{

{
// empty
Input: "",
Error: true,
},

{
// missing SubscriptionId
Input: "/",
Error: true,
},

{
// missing value for SubscriptionId
Input: "/subscriptions/",
Error: true,
},

{
// missing ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/",
Error: true,
},

{
// missing value for ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/",
Error: true,
},

{
// missing PrivateDnsZoneName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/",
Error: true,
},

{
// missing value for PrivateDnsZoneName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateDnsZones/",
Error: true,
},

{
// missing AName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateDnsZones/privateDnsZone1/",
Error: true,
},

{
// missing value for AName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateDnsZones/privateDnsZone1/A/",
Error: true,
},

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateDnsZones/privateDnsZone1/A/eh1",
Expected: &ARecordId{
SubscriptionId: "12345678-1234-9876-4563-123456789012",
ResourceGroup: "resGroup1",
PrivateDnsZoneName: "privateDnsZone1",
AName: "eh1",
},
},

{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/PRIVATEDNSZONES/PRIVATEDNSZONE1/A/EH1",
Error: true,
},
}

for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)

actual, err := ARecordID(v.Input)
if err != nil {
if v.Error {
continue
}

t.Fatalf("Expect a value but got an error: %s", err)
}
if v.Error {
t.Fatal("Expect an error but didn't get one")
}

if actual.SubscriptionId != v.Expected.SubscriptionId {
t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId)
}
if actual.ResourceGroup != v.Expected.ResourceGroup {
t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup)
}
if actual.PrivateDnsZoneName != v.Expected.PrivateDnsZoneName {
t.Fatalf("Expected %q but got %q for PrivateDnsZoneName", v.Expected.PrivateDnsZoneName, actual.PrivateDnsZoneName)
}
if actual.AName != v.Expected.AName {
t.Fatalf("Expected %q but got %q for AName", v.Expected.AName, actual.AName)
}
}
}
75 changes: 75 additions & 0 deletions internal/services/privatedns/parse/aaaa_record.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package parse

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import (
"fmt"
"strings"

"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
)

type AaaaRecordId struct {
SubscriptionId string
ResourceGroup string
PrivateDnsZoneName string
AAAAName string
}

func NewAaaaRecordID(subscriptionId, resourceGroup, privateDnsZoneName, aAAAName string) AaaaRecordId {
return AaaaRecordId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
PrivateDnsZoneName: privateDnsZoneName,
AAAAName: aAAAName,
}
}

func (id AaaaRecordId) String() string {
segments := []string{
fmt.Sprintf("A A A A Name %q", id.AAAAName),
fmt.Sprintf("Private Dns Zone Name %q", id.PrivateDnsZoneName),
fmt.Sprintf("Resource Group %q", id.ResourceGroup),
}
segmentsStr := strings.Join(segments, " / ")
return fmt.Sprintf("%s: (%s)", "Aaaa Record", segmentsStr)
}

func (id AaaaRecordId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateDnsZones/%s/AAAA/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.PrivateDnsZoneName, id.AAAAName)
}

// AaaaRecordID parses a AaaaRecord ID into an AaaaRecordId struct
func AaaaRecordID(input string) (*AaaaRecordId, error) {
id, err := resourceids.ParseAzureResourceID(input)
if err != nil {
return nil, err
}

resourceId := AaaaRecordId{
SubscriptionId: id.SubscriptionID,
ResourceGroup: id.ResourceGroup,
}

if resourceId.SubscriptionId == "" {
return nil, fmt.Errorf("ID was missing the 'subscriptions' element")
}

if resourceId.ResourceGroup == "" {
return nil, fmt.Errorf("ID was missing the 'resourceGroups' element")
}

if resourceId.PrivateDnsZoneName, err = id.PopSegment("privateDnsZones"); err != nil {
return nil, err
}
if resourceId.AAAAName, err = id.PopSegment("AAAA"); err != nil {
return nil, err
}

if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, err
}

return &resourceId, nil
}
Loading