Skip to content

Commit

Permalink
Merge pull request #7023 from ArcturusZhang/fix-VMSS-name-cannot-end-…
Browse files Browse the repository at this point in the history
…with-upper-case-letters

Update VM name and VMSS name validation rule - now names can end with upper case letters
  • Loading branch information
tombuildsstuff committed May 20, 2020
2 parents c2472a4 + afd8302 commit 336cc52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion azurerm/internal/services/compute/validation.go
Expand Up @@ -35,7 +35,7 @@ func ValidateVmName(i interface{}, k string) (warnings []string, errors []error)
errors = append(errors, fmt.Errorf("%q must begin with an alphanumeric character", k))
}

if matched := regexp.MustCompile(`[a-z0-9_]$`).Match([]byte(v)); !matched {
if matched := regexp.MustCompile(`\w$`).Match([]byte(v)); !matched {
errors = append(errors, fmt.Errorf("%q must end with an alphanumeric character or underscore", k))
}

Expand Down
10 changes: 10 additions & 0 deletions azurerm/internal/services/compute/validation_test.go
Expand Up @@ -72,6 +72,16 @@ func TestValidateVmName(t *testing.T) {
input: "12345",
expected: false,
},
{
// can start with upper case letter
input: "Test",
expected: true,
},
{
// can end with upper case letter
input: "TEST",
expected: true,
},
}

for _, v := range testData {
Expand Down

0 comments on commit 336cc52

Please sign in to comment.