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_api_portal_custom_domain #16966

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 @@ -7,6 +7,7 @@ import (

type Client struct {
APIPortalClient *appplatform.APIPortalsClient
APIPortalCustomDomainClient *appplatform.APIPortalCustomDomainsClient
AppsClient *appplatform.AppsClient
BindingsClient *appplatform.BindingsClient
BuildPackBindingClient *appplatform.BuildpackBindingClient
Expand All @@ -30,6 +31,9 @@ func NewClient(o *common.ClientOptions) *Client {
apiPortalClient := appplatform.NewAPIPortalsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&apiPortalClient.Client, o.ResourceManagerAuthorizer)

apiPortalCustomDomainClient := appplatform.NewAPIPortalCustomDomainsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&apiPortalCustomDomainClient.Client, o.ResourceManagerAuthorizer)

appsClient := appplatform.NewAppsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&appsClient.Client, o.ResourceManagerAuthorizer)

Expand Down Expand Up @@ -83,6 +87,7 @@ func NewClient(o *common.ClientOptions) *Client {

return &Client{
APIPortalClient: &apiPortalClient,
APIPortalCustomDomainClient: &apiPortalCustomDomainClient,
AppsClient: &appsClient,
BindingsClient: &bindingsClient,
BuildPackBindingClient: &buildpackBindingClient,
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 SpringCloudAPIPortalCustomDomainId struct {
SubscriptionId string
ResourceGroup string
SpringName string
ApiPortalName string
DomainName string
}

func NewSpringCloudAPIPortalCustomDomainID(subscriptionId, resourceGroup, springName, apiPortalName, domainName string) SpringCloudAPIPortalCustomDomainId {
return SpringCloudAPIPortalCustomDomainId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
SpringName: springName,
ApiPortalName: apiPortalName,
DomainName: domainName,
}
}

func (id SpringCloudAPIPortalCustomDomainId) String() string {
segments := []string{
fmt.Sprintf("Domain Name %q", id.DomainName),
fmt.Sprintf("Api Portal Name %q", id.ApiPortalName),
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 A P I Portal Custom Domain", segmentsStr)
}

func (id SpringCloudAPIPortalCustomDomainId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AppPlatform/Spring/%s/apiPortals/%s/domains/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SpringName, id.ApiPortalName, id.DomainName)
}

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

resourceId := SpringCloudAPIPortalCustomDomainId{
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.ApiPortalName, err = id.PopSegment("apiPortals"); err != nil {
return nil, err
}
if resourceId.DomainName, err = id.PopSegment("domains"); 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 = SpringCloudAPIPortalCustomDomainId{}

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

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

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

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

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

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

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/apiPortals/apiPortal1/domains/domain1",
Expected: &SpringCloudAPIPortalCustomDomainId{
SubscriptionId: "12345678-1234-9876-4563-123456789012",
ResourceGroup: "resourceGroup1",
SpringName: "service1",
ApiPortalName: "apiPortal1",
DomainName: "domain1",
},
},

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

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

actual, err := SpringCloudAPIPortalCustomDomainID(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.ApiPortalName != v.Expected.ApiPortalName {
t.Fatalf("Expected %q but got %q for ApiPortalName", v.Expected.ApiPortalName, actual.ApiPortalName)
}
if actual.DomainName != v.Expected.DomainName {
t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName)
}
}
}
1 change: 1 addition & 0 deletions internal/services/springcloud/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
return map[string]*pluginsdk.Resource{
"azurerm_spring_cloud_active_deployment": resourceSpringCloudActiveDeployment(),
"azurerm_spring_cloud_api_portal": resourceSpringCloudAPIPortal(),
"azurerm_spring_cloud_api_portal_custom_domain": resourceSpringCloudAPIPortalCustomDomain(),
"azurerm_spring_cloud_app": resourceSpringCloudApp(),
"azurerm_spring_cloud_app_cosmosdb_association": resourceSpringCloudAppCosmosDBAssociation(),
"azurerm_spring_cloud_app_mysql_association": resourceSpringCloudAppMysqlAssociation(),
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 @@ -3,6 +3,7 @@ package springcloud
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudApp -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudAppAssociation -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/bindings/bind1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudAPIPortal -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/apiPortals/apiPortal1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudAPIPortalCustomDomain -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/apiPortals/apiPortal1/domains/domain1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudBuildServiceBuilder -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/buildServices/buildService1/builders/builder1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudBuildPackBinding -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.AppPlatform/Spring/service1/buildServices/buildService1/builders/builder1/buildpackBindings/buildpackBinding1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SpringCloudDeployment -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/deployments/deploy1
Expand Down
Loading