Skip to content

Commit

Permalink
follow up of PR #8095
Browse files Browse the repository at this point in the history
  • Loading branch information
njuCZ authored Sep 11, 2020
1 parent a28ee49 commit d7aad8b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
12 changes: 12 additions & 0 deletions azurerm/internal/services/mssql/parse/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ type MsSqlDatabaseExtendedAuditingPolicyId struct {
ResourceGroup string
}

func NewMsSqlDatabaseID(resourceGroup, msSqlServer, name string) MsSqlDatabaseId {
return MsSqlDatabaseId{
ResourceGroup: resourceGroup,
MsSqlServer: msSqlServer,
Name: name,
}
}

func (id MsSqlDatabaseId) ID(subscriptionId string) string {
return fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Sql/servers/%s/databases/%s", subscriptionId, id.ResourceGroup, id.MsSqlServer, id.Name)
}

func MsSqlDatabaseID(input string) (*MsSqlDatabaseId, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions azurerm/internal/services/mssql/parse/mssql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ package parse

import (
"testing"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid"
)

var _ resourceid.Formatter = MsSqlDatabaseId{}

func TestMsSqlDatabaseID(t *testing.T) {
testData := []struct {
Name string
Expand Down
13 changes: 6 additions & 7 deletions azurerm/internal/services/synapse/synapse_sql_pool_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
postgresValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/postgres/validate"
sqlParse "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sql/parse"
sqlValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sql/validate"
mssqlParse "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/mssql/parse"
mssqlValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/mssql/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/synapse/parse"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/synapse/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
Expand Down Expand Up @@ -113,7 +112,7 @@ func resourceArmSynapseSqlPool() *schema.Resource {
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: postgresValidate.PostgresDatabaseCollation,
ValidateFunc: mssqlValidate.MsSqlDBCollation(),
},

"recovery_database_id": {
Expand All @@ -123,7 +122,7 @@ func resourceArmSynapseSqlPool() *schema.Resource {
ConflictsWith: []string{"restore"},
ValidateFunc: validation.Any(
validate.SqlPoolID,
sqlValidate.SqlDatabaseID,
mssqlValidate.MsSqlDatabaseID,
),
},

Expand All @@ -148,7 +147,7 @@ func resourceArmSynapseSqlPool() *schema.Resource {
ForceNew: true,
ValidateFunc: validation.Any(
validate.SqlPoolID,
sqlValidate.SqlDatabaseID,
mssqlValidate.MsSqlDatabaseID,
),
},
},
Expand Down Expand Up @@ -411,5 +410,5 @@ func constructSourceDatabaseId(id string, subscriptionId string) string {
if err != nil {
return id
}
return sqlParse.NewSqlDatabaseID(sqlPoolId.Workspace.ResourceGroup, sqlPoolId.Workspace.Name, sqlPoolId.Name).ID(subscriptionId)
return mssqlParse.NewMsSqlDatabaseID(sqlPoolId.Workspace.ResourceGroup, sqlPoolId.Workspace.Name, sqlPoolId.Name).ID(subscriptionId)
}

0 comments on commit d7aad8b

Please sign in to comment.