Skip to content

Commit

Permalink
Azure RM loadbalancer rules have correct naming restrictions
Browse files Browse the repository at this point in the history
- The name cannot be empty
- The name cannot be more than 80 characters
- The name must begin with a letter or number
- The name must end with a letter, number, or underscore
- The name must only contain letters, numbers, underscores, periods, or hyphens
  • Loading branch information
wendorf committed Oct 20, 2016
1 parent 0fe51b3 commit 691ae70
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions builtin/providers/azurerm/resource_arm_loadbalancer_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ func expandAzureRmLoadBalancerRule(d *schema.ResourceData, lb *network.LoadBalan

func validateArmLoadBalancerRuleName(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if !regexp.MustCompile(`^[a-zA-Z._-]+$`).MatchString(value) {
if !regexp.MustCompile(`^[a-zA-Z_0-9.-]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"only word characters and hyphens allowed in %q: %q",
"only word characters, numbers, underscores, periods, and hyphens allowed in %q: %q",
k, value))
}

Expand All @@ -339,14 +339,14 @@ func validateArmLoadBalancerRuleName(v interface{}, k string) (ws []string, erro
errors = append(errors, fmt.Errorf(
"%q cannot be an empty string: %q", k, value))
}
if !regexp.MustCompile(`[a-zA-Z]$`).MatchString(value) {
if !regexp.MustCompile(`[a-zA-Z0-9_]$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q must end with a word character: %q", k, value))
"%q must end with a word character, number, or underscore: %q", k, value))
}

if !regexp.MustCompile(`^[a-zA-Z]`).MatchString(value) {
if !regexp.MustCompile(`^[a-zA-Z0-9]`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q must start with a word character: %q", k, value))
"%q must start with a word character or number: %q", k, value))
}

return
Expand Down

0 comments on commit 691ae70

Please sign in to comment.