Skip to content

Commit

Permalink
New Resource: azurerm_service_fabric_mesh_application (#6761)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfrahry authored Oct 2, 2020
1 parent ff36d5b commit 3e637f5
Show file tree
Hide file tree
Showing 27 changed files with 9,455 additions and 0 deletions.
3 changes: 3 additions & 0 deletions azurerm/internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import (
sentinel "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sentinel/client"
serviceBus "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicebus/client"
serviceFabric "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabric/client"
serviceFabricMesh "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh/client"
signalr "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr/client"
sql "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sql/client"
storage "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/storage/client"
Expand Down Expand Up @@ -163,6 +164,7 @@ type Client struct {
Sentinel *sentinel.Client
ServiceBus *serviceBus.Client
ServiceFabric *serviceFabric.Client
ServiceFabricMesh *serviceFabricMesh.Client
SignalR *signalr.Client
Storage *storage.Client
StreamAnalytics *streamAnalytics.Client
Expand Down Expand Up @@ -251,6 +253,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
client.Sentinel = sentinel.NewClient(o)
client.ServiceBus = serviceBus.NewClient(o)
client.ServiceFabric = serviceFabric.NewClient(o)
client.ServiceFabricMesh = serviceFabricMesh.NewClient(o)
client.SignalR = signalr.NewClient(o)
client.Sql = sql.NewClient(o)
client.Storage = storage.NewClient(o)
Expand Down
2 changes: 2 additions & 0 deletions azurerm/internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sentinel"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicebus"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabric"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sql"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/storage"
Expand Down Expand Up @@ -155,6 +156,7 @@ func SupportedServices() []common.ServiceRegistration {
sentinel.Registration{},
servicebus.Registration{},
servicefabric.Registration{},
servicefabricmesh.Registration{},
signalr.Registration{},
sql.Registration{},
storage.Registration{},
Expand Down
1 change: 1 addition & 0 deletions azurerm/internal/resourceproviders/required.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Required() map[string]struct{} {
"Microsoft.SecurityInsights": {},
"Microsoft.ServiceBus": {},
"Microsoft.ServiceFabric": {},
"Microsoft.ServiceFabricMesh": {},
"Microsoft.Sql": {},
"Microsoft.Storage": {},
"Microsoft.StreamAnalytics": {},
Expand Down
24 changes: 24 additions & 0 deletions azurerm/internal/services/servicefabricmesh/client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)

type Client struct {
ApplicationClient *servicefabricmesh.ApplicationClient
ServiceClient *servicefabricmesh.ServiceClient
}

func NewClient(o *common.ClientOptions) *Client {
applicationsClient := servicefabricmesh.NewApplicationClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&applicationsClient.Client, o.ResourceManagerAuthorizer)

servicesClient := servicefabricmesh.NewServiceClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&servicesClient.Client, o.ResourceManagerAuthorizer)

return &Client{
ApplicationClient: &applicationsClient,
ServiceClient: &servicesClient,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package parse

import (
"fmt"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)

type ServiceFabricMeshApplicationId struct {
ResourceGroup string
Name string
}

func ServiceFabricMeshApplicationID(input string) (*ServiceFabricMeshApplicationId, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("[ERROR] Unable to parse Service Fabric Mesh Application ID %q: %+v", input, err)
}

cluster := ServiceFabricMeshApplicationId{
ResourceGroup: id.ResourceGroup,
}

if cluster.Name, err = id.PopSegment("applications"); err != nil {
return nil, err
}

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

return &cluster, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package parse

import (
"testing"
)

func TestServiceFabricMeshApplicationId(t *testing.T) {
testData := []struct {
Name string
Input string
Expected *ServiceFabricMeshApplicationId
}{
{
Name: "Empty",
Input: "",
Expected: nil,
},
{
Name: "No Resource Groups Segment",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000",
Expected: nil,
},
{
Name: "No Resource Groups Value",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/",
Expected: nil,
},
{
Name: "Resource Group ID",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/",
Expected: nil,
},
{
Name: "Missing Applications Value",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ServiceFabricMesh/applications/",
Expected: nil,
},
{
Name: "Service Fabric Mesh Application ID",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ServiceFabricMesh/applications/Application1",
Expected: &ServiceFabricMeshApplicationId{
Name: "Application1",
ResourceGroup: "resGroup1",
},
},
{
Name: "Wrong Casing",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ServiceFabricMesh/Applications/Application1",
Expected: nil,
},
}

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

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

t.Fatalf("Expected a value but got an error: %s", err)
}

if actual.Name != v.Expected.Name {
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name)
}

if actual.ResourceGroup != v.Expected.ResourceGroup {
t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup)
}
}
}
29 changes: 29 additions & 0 deletions azurerm/internal/services/servicefabricmesh/registration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package servicefabricmesh

import "github.com/hashicorp/terraform-plugin-sdk/helper/schema"

type Registration struct{}

// Name is the name of this Service
func (r Registration) Name() string {
return "Service Fabric Mesh"
}

// WebsiteCategories returns a list of categories which can be used for the sidebar
func (r Registration) WebsiteCategories() []string {
return []string{
"Service Fabric Mesh",
}
}

// SupportedDataSources returns the supported Data Sources supported by this Service
func (r Registration) SupportedDataSources() map[string]*schema.Resource {
return map[string]*schema.Resource{}
}

// SupportedResources returns the supported Resources supported by this Service
func (r Registration) SupportedResources() map[string]*schema.Resource {
return map[string]*schema.Resource{
"azurerm_service_fabric_mesh_application": resourceArmServiceFabricMeshApplication(),
}
}
Loading

0 comments on commit 3e637f5

Please sign in to comment.