Skip to content
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

new resource azurerm_spring_cloud_gateway_route_config #16721

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions internal/services/springcloud/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Client struct {
CustomDomainsClient *appplatform.CustomDomainsClient
GatewayClient *appplatform.GatewaysClient
GatewayCustomDomainClient *appplatform.GatewayCustomDomainsClient
GatewayRouteConfigClient *appplatform.GatewayRouteConfigsClient
MonitoringSettingsClient *appplatform.MonitoringSettingsClient
DeploymentsClient *appplatform.DeploymentsClient
ServicesClient *appplatform.ServicesClient
Expand Down Expand Up @@ -57,6 +58,9 @@ func NewClient(o *common.ClientOptions) *Client {
gatewayCustomDomainClient := appplatform.NewGatewayCustomDomainsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&gatewayCustomDomainClient.Client, o.ResourceManagerAuthorizer)

gatewayRouteConfigClient := appplatform.NewGatewayRouteConfigsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&gatewayRouteConfigClient.Client, o.ResourceManagerAuthorizer)

monitoringSettingsClient := appplatform.NewMonitoringSettingsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&monitoringSettingsClient.Client, o.ResourceManagerAuthorizer)

Expand All @@ -81,6 +85,7 @@ func NewClient(o *common.ClientOptions) *Client {
DeploymentsClient: &deploymentsClient,
GatewayClient: &gatewayClient,
GatewayCustomDomainClient: &gatewayCustomDomainClient,
GatewayRouteConfigClient: &gatewayRouteConfigClient,
MonitoringSettingsClient: &monitoringSettingsClient,
ServicesClient: &servicesClient,
ServiceRegistryClient: &serviceRegistryClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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 SpringCloudGatewayRouteConfigId struct {
SubscriptionId string
ResourceGroup string
SpringName string
GatewayName string
RouteConfigName string
}

func NewSpringCloudGatewayRouteConfigID(subscriptionId, resourceGroup, springName, gatewayName, routeConfigName string) SpringCloudGatewayRouteConfigId {
return SpringCloudGatewayRouteConfigId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
SpringName: springName,
GatewayName: gatewayName,
RouteConfigName: routeConfigName,
}
}

func (id SpringCloudGatewayRouteConfigId) String() string {
segments := []string{
fmt.Sprintf("Route Config Name %q", id.RouteConfigName),
fmt.Sprintf("Gateway Name %q", id.GatewayName),
fmt.Sprintf("Spring Name %q", id.SpringName),
fmt.Sprintf("Resource Group %q", id.ResourceGroup),
}
segmentsStr := strings.Join(segments, " / ")
return fmt.Sprintf("%s: (%s)", "Spring Cloud Gateway Route Config", segmentsStr)
}

func (id SpringCloudGatewayRouteConfigId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AppPlatform/Spring/%s/gateways/%s/routeConfigs/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SpringName, id.GatewayName, id.RouteConfigName)
}

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

resourceId := SpringCloudGatewayRouteConfigId{
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.SpringName, err = id.PopSegment("Spring"); err != nil {
return nil, err
}
if resourceId.GatewayName, err = id.PopSegment("gateways"); err != nil {
return nil, err
}
if resourceId.RouteConfigName, err = id.PopSegment("routeConfigs"); err != nil {
return nil, err
}

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

return &resourceId, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
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 = SpringCloudGatewayRouteConfigId{}

func TestSpringCloudGatewayRouteConfigIDFormatter(t *testing.T) {
actual := NewSpringCloudGatewayRouteConfigID("12345678-1234-9876-4563-123456789012", "resourceGroup1", "service1", "gateway1", "routeConfig1").ID()
expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/gateway1/routeConfigs/routeConfig1"
if actual != expected {
t.Fatalf("Expected %q but got %q", expected, actual)
}
}

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

{
// 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 SpringName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/",
Error: true,
},

{
// missing value for SpringName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/",
Error: true,
},

{
// missing GatewayName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/",
Error: true,
},

{
// missing value for GatewayName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/",
Error: true,
},

{
// missing RouteConfigName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/gateway1/",
Error: true,
},

{
// missing value for RouteConfigName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/gateway1/routeConfigs/",
Error: true,
},

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/gateway1/routeConfigs/routeConfig1",
Expected: &SpringCloudGatewayRouteConfigId{
SubscriptionId: "12345678-1234-9876-4563-123456789012",
ResourceGroup: "resourceGroup1",
SpringName: "service1",
GatewayName: "gateway1",
RouteConfigName: "routeConfig1",
},
},

{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.APPPLATFORM/SPRING/SERVICE1/GATEWAYS/GATEWAY1/ROUTECONFIGS/ROUTECONFIG1",
Error: true,
},
}

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

actual, err := SpringCloudGatewayRouteConfigID(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.SpringName != v.Expected.SpringName {
t.Fatalf("Expected %q but got %q for SpringName", v.Expected.SpringName, actual.SpringName)
}
if actual.GatewayName != v.Expected.GatewayName {
t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName)
}
if actual.RouteConfigName != v.Expected.RouteConfigName {
t.Fatalf("Expected %q but got %q for RouteConfigName", v.Expected.RouteConfigName, actual.RouteConfigName)
}
}
}
1 change: 1 addition & 0 deletions internal/services/springcloud/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
"azurerm_spring_cloud_custom_domain": resourceSpringCloudCustomDomain(),
"azurerm_spring_cloud_gateway": resourceSpringCloudGateway(),
"azurerm_spring_cloud_gateway_custom_domain": resourceSpringCloudGatewayCustomDomain(),
"azurerm_spring_cloud_gateway_route_config": resourceSpringCloudGatewayRouteConfig(),
"azurerm_spring_cloud_container_deployment": resourceSpringCloudContainerDeployment(),
"azurerm_spring_cloud_java_deployment": resourceSpringCloudJavaDeployment(),
"azurerm_spring_cloud_service": resourceSpringCloudService(),
Expand Down
1 change: 1 addition & 0 deletions internal/services/springcloud/resourceids.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ package springcloud
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudConfigurationService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/configurationServices/configurationService1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/gateway1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudGatewayCustomDomain -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/gateway1/domains/domain1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudGatewayRouteConfig -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/gateways/gateway1/routeConfigs/routeConfig1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudStorage -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/storages/storage1
Loading