-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new resource "azurerm_spring_cloud_java_deployment" and "azurerm_spri…
…ng_cloud_active_deployment" (#9959)
- Loading branch information
Showing
16 changed files
with
1,391 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
azurerm/internal/services/springcloud/parse/spring_cloud_deployment.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" | ||
) | ||
|
||
type SpringCloudDeploymentId struct { | ||
SubscriptionId string | ||
ResourceGroup string | ||
SpringName string | ||
AppName string | ||
DeploymentName string | ||
} | ||
|
||
func NewSpringCloudDeploymentID(subscriptionId, resourceGroup, springName, appName, deploymentName string) SpringCloudDeploymentId { | ||
return SpringCloudDeploymentId{ | ||
SubscriptionId: subscriptionId, | ||
ResourceGroup: resourceGroup, | ||
SpringName: springName, | ||
AppName: appName, | ||
DeploymentName: deploymentName, | ||
} | ||
} | ||
|
||
func (id SpringCloudDeploymentId) String() string { | ||
segments := []string{ | ||
fmt.Sprintf("Deployment Name %q", id.DeploymentName), | ||
fmt.Sprintf("App Name %q", id.AppName), | ||
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 Deployment", segmentsStr) | ||
} | ||
|
||
func (id SpringCloudDeploymentId) ID() string { | ||
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AppPlatform/Spring/%s/apps/%s/deployments/%s" | ||
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SpringName, id.AppName, id.DeploymentName) | ||
} | ||
|
||
// SpringCloudDeploymentID parses a SpringCloudDeployment ID into an SpringCloudDeploymentId struct | ||
func SpringCloudDeploymentID(input string) (*SpringCloudDeploymentId, error) { | ||
id, err := azure.ParseAzureResourceID(input) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resourceId := SpringCloudDeploymentId{ | ||
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.AppName, err = id.PopSegment("apps"); err != nil { | ||
return nil, err | ||
} | ||
if resourceId.DeploymentName, err = id.PopSegment("deployments"); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := id.ValidateNoEmptySegments(input); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &resourceId, nil | ||
} |
144 changes: 144 additions & 0 deletions
144
azurerm/internal/services/springcloud/parse/spring_cloud_deployment_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" | ||
) | ||
|
||
var _ resourceid.Formatter = SpringCloudDeploymentId{} | ||
|
||
func TestSpringCloudDeploymentIDFormatter(t *testing.T) { | ||
actual := NewSpringCloudDeploymentID("12345678-1234-9876-4563-123456789012", "resGroup1", "spring1", "app1", "deploy1").ID() | ||
expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/deployments/deploy1" | ||
if actual != expected { | ||
t.Fatalf("Expected %q but got %q", expected, actual) | ||
} | ||
} | ||
|
||
func TestSpringCloudDeploymentID(t *testing.T) { | ||
testData := []struct { | ||
Input string | ||
Error bool | ||
Expected *SpringCloudDeploymentId | ||
}{ | ||
|
||
{ | ||
// 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/resGroup1/providers/Microsoft.AppPlatform/", | ||
Error: true, | ||
}, | ||
|
||
{ | ||
// missing value for SpringName | ||
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/", | ||
Error: true, | ||
}, | ||
|
||
{ | ||
// missing AppName | ||
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/", | ||
Error: true, | ||
}, | ||
|
||
{ | ||
// missing value for AppName | ||
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/", | ||
Error: true, | ||
}, | ||
|
||
{ | ||
// missing DeploymentName | ||
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/", | ||
Error: true, | ||
}, | ||
|
||
{ | ||
// missing value for DeploymentName | ||
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/deployments/", | ||
Error: true, | ||
}, | ||
|
||
{ | ||
// valid | ||
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/deployments/deploy1", | ||
Expected: &SpringCloudDeploymentId{ | ||
SubscriptionId: "12345678-1234-9876-4563-123456789012", | ||
ResourceGroup: "resGroup1", | ||
SpringName: "spring1", | ||
AppName: "app1", | ||
DeploymentName: "deploy1", | ||
}, | ||
}, | ||
|
||
{ | ||
// upper-cased | ||
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.APPPLATFORM/SPRING/SPRING1/APPS/APP1/DEPLOYMENTS/DEPLOY1", | ||
Error: true, | ||
}, | ||
} | ||
|
||
for _, v := range testData { | ||
t.Logf("[DEBUG] Testing %q", v.Input) | ||
|
||
actual, err := SpringCloudDeploymentID(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.AppName != v.Expected.AppName { | ||
t.Fatalf("Expected %q but got %q for AppName", v.Expected.AppName, actual.AppName) | ||
} | ||
if actual.DeploymentName != v.Expected.DeploymentName { | ||
t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
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=SpringCloudDeployment -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/deployments/deploy1 | ||
//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 | ||
//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 |
Oops, something went wrong.