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

azurerm_kusto_database - allows underscores in name #19466

Merged
merged 2 commits into from
Nov 29, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions internal/services/kusto/kusto_database_resource_test.go
Expand Up @@ -45,6 +45,21 @@ func TestAccKustoDatabase_complete(t *testing.T) {
})
}

func TestAccKustoDatabase_name(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kusto_database", "test")
r := KustoDatabaseResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.name(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccKustoDatabase_softDeletePeriod(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kusto_database", "test")
r := KustoDatabaseResource{}
Expand Down Expand Up @@ -153,6 +168,37 @@ resource "azurerm_kusto_database" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger)
}

func (KustoDatabaseResource) name(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "rg" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_kusto_cluster" "cluster" {
name = "acctestkc%s"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name

sku {
name = "Dev(No SLA)_Standard_D11_v2"
capacity = 1
}
}

resource "azurerm_kusto_database" "test" {
name = "acctest_kd_%d"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
cluster_name = azurerm_kusto_cluster.cluster.name
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger)
}

func (KustoDatabaseResource) softDeletePeriod(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
4 changes: 2 additions & 2 deletions internal/services/kusto/validate/name.go
Expand Up @@ -62,8 +62,8 @@ func DatabaseName(v interface{}, k string) (warnings []string, errors []error) {
errors = append(errors, fmt.Errorf("%q must not consist of whitespaces only", k))
}

if !regexp.MustCompile(`^[a-zA-Z0-9\s.-]+$`).MatchString(name) {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters, whitespaces, dashes and dots: %q", k, name))
if !regexp.MustCompile(`^[a-zA-Z0-9\s._-]+$`).MatchString(name) {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters, whitespaces, dashes, underscores and dots: %q", k, name))
}

if len(name) > 260 {
Expand Down