Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit d485512

Browse files
authored
Merge pull request hashicorp#9468 from wendorf/arm_loadbalancer_rule_naming_fix
Azure RM loadbalancer rules have correct naming restrictions
2 parents e4ddf24 + 957d1cb commit d485512

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

builtin/providers/azurerm/resource_arm_loadbalancer_rule.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ func expandAzureRmLoadBalancerRule(d *schema.ResourceData, lb *network.LoadBalan
332332

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

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

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

360360
return

builtin/providers/azurerm/resource_arm_loadbalancer_rule_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestResourceAzureRMLoadBalancerRuleNameLabel_validation(t *testing.T) {
2525
ErrCount: 1,
2626
},
2727
{
28-
Value: "test123test",
28+
Value: "test#test",
2929
ErrCount: 1,
3030
},
3131
{
@@ -48,6 +48,14 @@ func TestResourceAzureRMLoadBalancerRuleNameLabel_validation(t *testing.T) {
4848
Value: "TestRule",
4949
ErrCount: 0,
5050
},
51+
{
52+
Value: "Test123Rule",
53+
ErrCount: 0,
54+
},
55+
{
56+
Value: "TestRule",
57+
ErrCount: 0,
58+
},
5159
}
5260

5361
for _, tc := range cases {

0 commit comments

Comments
 (0)