Skip to content

Commit

Permalink
plugin sdk在create时候将[]变为了null,但是在read时会会变成[]。这个提交借鉴了阿里云instace的se…
Browse files Browse the repository at this point in the history
…condary_ip属性的解决方案,通过将受影响的属性设置为Optional+Computed作为workaround
  • Loading branch information
shinny-taojiachun committed Dec 4, 2023
1 parent c32f3c2 commit 7575a6b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tencentcloud/resource_tc_mysql_privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ func resourceTencentCloudMysqlPrivilege() *schema.Resource {
Description: "Account host, default is `%`.",
},
"global": {
Type: schema.TypeSet,
Required: true,
Type: schema.TypeSet,
// Workaround: 将Required变为Optional+Computed.
// Issue: plugin sdk 会错误地在create时候把赋值给required的`[]`变为nullVal, 然后在read变回`[]`,
// 见 https://github.com/hashicorp/terraform-plugin-sdk/issues/766
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return helper.HashString(v.(string))
Expand Down

0 comments on commit 7575a6b

Please sign in to comment.