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_databricks_workspace - allow underscores in name #5548

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ func ValidateDatabricksWorkspaceName(i interface{}, k string) (warnings []string

// First, second, and last characters must be a letter or number with a total length between 3 to 64 characters
// NOTE: Restricted name to 30 characters because that is the restriction in Azure Portal even though the API supports 64 characters
if !regexp.MustCompile("^[a-zA-Z0-9]{2}[-a-zA-Z0-9]{0,27}[a-zA-Z0-9]{1}$").MatchString(v) {
if !regexp.MustCompile("^[a-zA-Z0-9]{2}[-_a-zA-Z0-9]{0,27}[a-zA-Z0-9]{1}$").MatchString(v) {
errors = append(errors, fmt.Errorf("%q must be 3 - 30 characters in length", k))
errors = append(errors, fmt.Errorf("%q first, second, and last characters must be a letter or number", k))
errors = append(errors, fmt.Errorf("%q can only contain letters, numbers, and hyphens", k))
errors = append(errors, fmt.Errorf("%q can only contain letters, numbers, underscores, and hyphens", k))
}

// No consecutive hyphens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func TestAzureRMDatabrickWorkspaceName(t *testing.T) {
Value: "hello-1-2-3-there",
ShouldError: false,
},
{
Value: "hello_1_2_3_there",
ShouldError: false,
},
{
Value: "hello-1-2-3-",
ShouldError: true,
Expand All @@ -38,6 +42,14 @@ func TestAzureRMDatabrickWorkspaceName(t *testing.T) {
Value: "-hello-1-2-3",
ShouldError: true,
},
{
Value: "hello_1_2_3_",
ShouldError: true,
},
{
Value: "_hello_1_2_3",
ShouldError: true,
},
{
Value: "hello!there",
ShouldError: true,
Expand Down