@@ -43,31 +43,19 @@ func resourceTencentCloudLB() *schema.Resource {
43
43
44
44
Schema : map [string ]* schema.Schema {
45
45
"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'." ,
57
51
},
58
52
"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'." ,
71
59
},
72
60
"name" : {
73
61
Type : schema .TypeString ,
@@ -111,7 +99,7 @@ func resourceTencentCloudLBCreate(d *schema.ResourceData, meta interface{}) erro
111
99
request .LoadBalancerType = stringToPointer (networkType )
112
100
113
101
if v , ok := d .GetOk ("forward" ); ok {
114
- if v == "CLASSIC" {
102
+ if v == lbForwardTypeClassic {
115
103
request .Forward = int64ToPointer (0 )
116
104
} else {
117
105
request .Forward = int64ToPointer (1 )
@@ -251,6 +239,7 @@ func resourceTencentCloudLBUpdate(d *schema.ResourceData, meta interface{}) erro
251
239
}
252
240
253
241
d .SetPartial ("name" )
242
+ d .Partial (false )
254
243
255
244
return resourceTencentCloudLBRead (d , meta )
256
245
}
0 commit comments