Skip to content

Commit

Permalink
Merge pull request #23974 from richsage/sqldb-hyperscale
Browse files Browse the repository at this point in the history
`azure_mssql_database` - support additional SKUs for Hyperscale tier
  • Loading branch information
tombuildsstuff authored Nov 21, 2023
2 parents 844415e + aad99e7 commit a46ece2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/services/mssql/validate/database_sku_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ const (
Gen5 = "(GP|HS|BC)_Gen5_(2|4|6|8|10|12|14|16|18|20|24|32|40|80)"
ServerlessGen5 = "(GP|HS)_S_Gen5_(1|2|4|6|8|10|12|14|16|18|20|24|32|40|80)"
Fsv2 = "(GP_Fsv2_(8|10|12|14|16|18|20|24|32|36|72))"
Dc = "((GP|BC|HS)_DC_(2|4|6|8))"
Dc = "((GP|BC|HS)_DC_(2|4|6|8|10|12|14|16|18|20|32|40))"
EightIM = "(HS_8IM_(24|48|80))"
Serverless8IM = "(HS_S_8IM_(24|80))"
Premium8IM = "(HS_PRMS_(2|4|6|8|10|12|14|16|18|20|24|32|40|64|80|128))"
Premium8IH = "(HS_MOPRMS_(2|4|6|8|10|12|14|16|18|20|24|32|40|64|80))"
)

func DatabaseSkuName() pluginsdk.SchemaValidateFunc {
pattern := "(?i)(^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$)"
return validation.StringMatch(regexp.MustCompile(fmt.Sprintf(pattern, Free, Basic, Elastic, Standard, Premium, DataWarehouse, Stretch, BusinessCritical, Gen4, Gen5, ServerlessGen5, Fsv2, Dc, EightIM, Serverless8IM)),
pattern := "(?i)(^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$|^%s$)"
return validation.StringMatch(regexp.MustCompile(fmt.Sprintf(pattern, Free, Basic, Elastic, Standard, Premium, DataWarehouse, Stretch, BusinessCritical, Gen4, Gen5, ServerlessGen5, Fsv2, Dc, EightIM, Serverless8IM, Premium8IM, Premium8IH)),

`This is not a valid sku name. For example, a valid sku name is 'GP_S_Gen5_1','HS_Gen4_1','BC_Gen5_2', 'ElasticPool', 'Basic', 'S0', 'P1'.`,
)
Expand Down
20 changes: 20 additions & 0 deletions internal/services/mssql/validate/database_sku_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ func TestDatabaseSkuName(t *testing.T) {
input: "HS_S_8IM_48",
valid: false,
},
{
name: "Valid Premium 8IM",
input: "HS_PRMS_8",
valid: true,
},
{
name: "Invalid Premium 8IM",
input: "HS_PRMS_28",
valid: false,
},
{
name: "Valid Premium 8IH",
input: "HS_MOPRMS_8",
valid: true,
},
{
name: "Invalid Premium 8IH",
input: "HS_MOPRMS_128",
valid: false,
},
}
validationFunction := DatabaseSkuName()
for _, tt := range tests {
Expand Down

0 comments on commit a46ece2

Please sign in to comment.