Skip to content

Commit 3e23cf9

Browse files
committed
replace string with const value
1 parent 630a7ce commit 3e23cf9

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

tencentcloud/resource_tc_lb.go

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,19 @@ func resourceTencentCloudLB() *schema.Resource {
4343

4444
Schema: map[string]*schema.Schema{
4545
"type": {
46-
Type: schema.TypeString,
47-
Required: true,
48-
ForceNew: true,
49-
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
50-
value := v.(string)
51-
if value != lbNetworkTypeOpen && value != lbNetworkTypeInternal {
52-
errors = append(errors, fmt.Errorf("Invalid value %s for '%s', choices: OPEN, INTERNAL", value, k))
53-
}
54-
return
55-
},
56-
Description: "The network type of the LB, valid choices: 'OPEN', 'INTERNAL'.",
46+
Type: schema.TypeString,
47+
Required: true,
48+
ForceNew: true,
49+
ValidateFunc: validateAllowedStringValue([]string{lbNetworkTypeOpen, lbNetworkTypeInternal}),
50+
Description: "The network type of the LB, valid choices: 'OPEN', 'INTERNAL'.",
5751
},
5852
"forward": {
59-
Type: schema.TypeString,
60-
Optional: true,
61-
ForceNew: true,
62-
Computed: true,
63-
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
64-
value := v.(string)
65-
if value != lbForwardTypeClassic && value != lbForwardTypeApplication {
66-
errors = append(errors, fmt.Errorf("Invalid value %s for '%s', choices: CLASSIC, APPLICATION", value, k))
67-
}
68-
return
69-
},
70-
Description: "The type of the LB, valid choices: 'CLASSIC', 'APPLICATION'.",
53+
Type: schema.TypeString,
54+
Optional: true,
55+
ForceNew: true,
56+
Computed: true,
57+
ValidateFunc: validateAllowedStringValue([]string{lbForwardTypeClassic, lbForwardTypeApplication}),
58+
Description: "The type of the LB, valid choices: 'CLASSIC', 'APPLICATION'.",
7159
},
7260
"name": {
7361
Type: schema.TypeString,
@@ -111,7 +99,7 @@ func resourceTencentCloudLBCreate(d *schema.ResourceData, meta interface{}) erro
11199
request.LoadBalancerType = stringToPointer(networkType)
112100

113101
if v, ok := d.GetOk("forward"); ok {
114-
if v == "CLASSIC" {
102+
if v == lbForwardTypeClassic {
115103
request.Forward = int64ToPointer(0)
116104
} else {
117105
request.Forward = int64ToPointer(1)
@@ -251,6 +239,7 @@ func resourceTencentCloudLBUpdate(d *schema.ResourceData, meta interface{}) erro
251239
}
252240

253241
d.SetPartial("name")
242+
d.Partial(false)
254243

255244
return resourceTencentCloudLBRead(d, meta)
256245
}

0 commit comments

Comments
 (0)