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_storage_share_directory Allow uppercase characters #4178

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions azurerm/helpers/validate/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ func StorageShareDirectoryName(v interface{}, k string) (warnings []string, erro
// File share names can contain only lowercase letters, numbers, and hyphens,
// and must begin and end with a letter or a number.
// however they can be nested (e.g. foo/bar)
if !regexp.MustCompile(`^[a-z0-9][a-z0-9-]+[a-z0-9]$`).MatchString(value) && !regexp.MustCompile(`^[a-z0-9]{1,}/[a-z0-9]{1,}$`).MatchString(value) {
errors = append(errors, fmt.Errorf("%s must contain only lowercase alphanumeric characters, numbers and hyphens. It must start and end with a letter and end only with a number or letter", k))
if !regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$`).MatchString(value) && !regexp.MustCompile(`^[A-Za-z0-9]{1,}/[A-Za-z0-9]{1,}$`).MatchString(value) {
errors = append(errors, fmt.Errorf("%s must contain only uppercase and lowercase alphanumeric characters, numbers and hyphens. It must start and end with a letter and end only with a number or letter", k))
}

// The name cannot contain two consecutive hyphens.
Expand Down
12 changes: 12 additions & 0 deletions azurerm/helpers/validate/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ func TestValidateStorageShareDirectoryName(t *testing.T) {
Input: "hello/",
Expected: false,
},
{
Input: "Abc123",
Expected: true,
},
{
Input: "abc123A",
Expected: true,
},
{
Input: "abC123",
Expected: true,
},
}

for _, v := range testCases {
Expand Down