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_dev_tool_portal #19568

Merged
Merged
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
5 changes: 5 additions & 0 deletions internal/services/springcloud/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Client struct {
ConfigServersClient *appplatform.ConfigServersClient
ConfigurationServiceClient *appplatform.ConfigurationServicesClient
CustomDomainsClient *appplatform.CustomDomainsClient
DevToolPortalClient *appplatform.DevToolPortalsClient
GatewayClient *appplatform.GatewaysClient
GatewayCustomDomainClient *appplatform.GatewayCustomDomainsClient
GatewayRouteConfigClient *appplatform.GatewayRouteConfigsClient
Expand Down Expand Up @@ -72,6 +73,9 @@ func NewClient(o *common.ClientOptions) *Client {
deploymentsClient := appplatform.NewDeploymentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&deploymentsClient.Client, o.ResourceManagerAuthorizer)

devToolPortalClient := appplatform.NewDevToolPortalsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&devToolPortalClient.Client, o.ResourceManagerAuthorizer)

gatewayClient := appplatform.NewGatewaysClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&gatewayClient.Client, o.ResourceManagerAuthorizer)

Expand Down Expand Up @@ -108,6 +112,7 @@ func NewClient(o *common.ClientOptions) *Client {
ConfigurationServiceClient: &configurationServiceClient,
CustomDomainsClient: &customDomainsClient,
DeploymentsClient: &deploymentsClient,
DevToolPortalClient: &devToolPortalClient,
GatewayClient: &gatewayClient,
GatewayCustomDomainClient: &gatewayCustomDomainClient,
GatewayRouteConfigClient: &gatewayRouteConfigClient,
Expand Down
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 SpringCloudDevToolPortalId struct {
SubscriptionId string
ResourceGroup string
SpringName string
DevToolPortalName string
}

func NewSpringCloudDevToolPortalID(subscriptionId, resourceGroup, springName, devToolPortalName string) SpringCloudDevToolPortalId {
return SpringCloudDevToolPortalId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
SpringName: springName,
DevToolPortalName: devToolPortalName,
}
}

func (id SpringCloudDevToolPortalId) String() string {
segments := []string{
fmt.Sprintf("Dev Tool Portal Name %q", id.DevToolPortalName),
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 Dev Tool Portal", segmentsStr)
}

func (id SpringCloudDevToolPortalId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AppPlatform/Spring/%s/DevToolPortals/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SpringName, id.DevToolPortalName)
}

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

resourceId := SpringCloudDevToolPortalId{
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.DevToolPortalName, err = id.PopSegment("DevToolPortals"); 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,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 = SpringCloudDevToolPortalId{}

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

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

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

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

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/DevToolPortals/default",
Expected: &SpringCloudDevToolPortalId{
SubscriptionId: "12345678-1234-9876-4563-123456789012",
ResourceGroup: "resourceGroup1",
SpringName: "service1",
DevToolPortalName: "default",
},
},

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

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

actual, err := SpringCloudDevToolPortalID(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.DevToolPortalName != v.Expected.DevToolPortalName {
t.Fatalf("Expected %q but got %q for DevToolPortalName", v.Expected.DevToolPortalName, actual.DevToolPortalName)
}
}
}
1 change: 1 addition & 0 deletions internal/services/springcloud/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@ func (r Registration) Resources() []sdk.Resource {
return []sdk.Resource{
SpringCloudAcceleratorResource{},
SpringCloudApplicationLiveViewResource{},
SpringCloudDevToolPortalResource{},
}
}
1 change: 1 addition & 0 deletions internal/services/springcloud/resourceids.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package springcloud
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudCertificate -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/spring/spring1/certificates/cert1 -rewrite=true
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudCustomDomain -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/spring/spring1/apps/app1/domains/domain.com -rewrite=true
//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 -rewrite=true
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudDevToolPortal -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/DevToolPortals/default
//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 -rewrite=true
//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 -rewrite=true
//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 -rewrite=true
Expand Down
Loading