Skip to content

feat(tke): [120601766] tke addon support update_strategy #2947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/2947.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/tencentcloud_kubernetes_addon: support `update_strategy`
```

```release-note:enhancement
resource/tencentcloud_kubernetes_addon_config: support `update_strategy`
```
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1034
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.970
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1034
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1038
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1014
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
Expand Down Expand Up @@ -91,7 +91,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq v1.0.955
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.1013
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1038
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.947
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1031/go.mod
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1033/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1034 h1:T7ewuO2DD+5R2LRpD2kTRy25aCkVDVdYkmmyUS63i08=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1034/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1038 h1:tB3DLzyQXavvGTI+JUvEcuYh0EtTn1rvh9W6xxFHL38=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1038/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
Expand Down Expand Up @@ -1030,6 +1032,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc v1.0.998 h1:f4/n0d
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc v1.0.998/go.mod h1:fyi/HUwCwVe2NCCCjz8k/C5GwPu3QazCZO+OBJ3MhLk=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031 h1:0Ew48YnVO+Sd2U3VrWgV36uRySTF7uOOFJH0Hd4ufhg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031/go.mod h1:KcKTYEXZil0FciUtQ75svPL4hZpLYVnemAeW27N3OKY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1038 h1:tmK0aSj8zJrTx7aubJR8DBvtySj1uO8UdFANUDFtbmo=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1038/go.mod h1:tWS3IluLYbNDx1kz8bBFEP6H1bxvuBPPGQ2WogD2rXI=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.947 h1:iZfuU8S86kfqFsAVT/LUApP8L5cpT90hl2wSKiUDVvw=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.947/go.mod h1:eAgJ+XUEhffMq79zjpgHoR3PBVcciSg+LuPDC8hLWsE=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857 h1:TkJnvSeRSXsRCwOwcwXSvruSK9s/kw8LC3FLeccw+A0=
Expand Down
26 changes: 19 additions & 7 deletions tencentcloud/services/tke/resource_tc_kubernetes_addon.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tencentcloud/services/tke/resource_tc_kubernetes_addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "tencentcloud_kubernetes_addon" "kubernetes_addon" {
cluster_id = tencentcloud_kubernetes_cluster.example.id
addon_name = "cos"
addon_version = "2018-05-25"
raw_values = "e30="
raw_values = "{\"tolerations\":[{\"key\":\"test\",\"value\":\"100\",\"operator\":\"Equal\"}]}"
}

```
Expand Down
25 changes: 18 additions & 7 deletions tencentcloud/services/tke/resource_tc_kubernetes_addon_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func ResourceTencentCloudKubernetesAddonConfig() *schema.Resource {
Description: "Version of addon.",
},

"update_strategy": {
Type: schema.TypeString,
Optional: true,
Description: "The update strategy of Addon parameters. Valid values are: `replace` and `merge`. The default value is merge, which is compatible with the old version API. `replace`: Use the new RawValues to completely replace the original RawValues of Addon. `merge`: Add or update the corresponding parameters in the original RawValues of Addon according to the new RawValues. Only valid in update addon process.",
},

"raw_values": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -110,12 +116,13 @@ func resourceTencentCloudKubernetesAddonConfigRead(d *schema.ResourceData, meta
_ = d.Set("addon_version", respData.AddonVersion)
}

if respData.RawValues != nil {
rawValues := respData.RawValues
base64DecodeValues, _ := base64.StdEncoding.DecodeString(*rawValues)
jsonValues := string(base64DecodeValues)
_ = d.Set("raw_values", jsonValues)
}
// describe cannot return the correct raw_values when included the update_strategy
// if respData.RawValues != nil {
// rawValues := respData.RawValues
// base64DecodeValues, _ := base64.StdEncoding.DecodeString(*rawValues)
// jsonValues := string(base64DecodeValues)
// _ = d.Set("raw_values", jsonValues)
// }

if respData.Phase != nil {
_ = d.Set("phase", respData.Phase)
Expand Down Expand Up @@ -145,7 +152,7 @@ func resourceTencentCloudKubernetesAddonConfigUpdate(d *schema.ResourceData, met
addonName := idSplit[1]

needChange := false
mutableArgs := []string{"addon_version", "raw_values"}
mutableArgs := []string{"addon_version", "raw_values", "update_strategy"}
for _, v := range mutableArgs {
if d.HasChange(v) {
needChange = true
Expand All @@ -169,6 +176,10 @@ func resourceTencentCloudKubernetesAddonConfigUpdate(d *schema.ResourceData, met
request.RawValues = &rawValues
}

if v, ok := d.GetOk("update_strategy"); ok {
request.UpdateStrategy = helper.String(v.(string))
}

err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTkeClient().UpdateAddonWithContext(ctx, request)
if e != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.970
## explicit; go 1.14
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1034
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1038
## explicit; go 1.11
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors
Expand Down Expand Up @@ -1324,7 +1324,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc v1.0.998
## explicit; go 1.14
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc/v20230321
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1038
## explicit; go 1.14
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20220501
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/kubernetes_addon.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ resource "tencentcloud_kubernetes_addon" "kubernetes_addon" {
cluster_id = tencentcloud_kubernetes_cluster.example.id
addon_name = "cos"
addon_version = "2018-05-25"
raw_values = "e30="
raw_values = "{\"tolerations\":[{\"key\":\"test\",\"value\":\"100\",\"operator\":\"Equal\"}]}"
}
```

Expand All @@ -45,6 +45,7 @@ The following arguments are supported:
* `cluster_id` - (Required, String, ForceNew) ID of cluster.
* `addon_version` - (Optional, String) Version of addon.
* `raw_values` - (Optional, String) Params of addon, base64 encoded json format.
* `update_strategy` - (Optional, String) The update strategy of Addon parameters. Valid values are: `replace` and `merge`. The default value is merge, which is compatible with the old version API. `replace`: Use the new RawValues to completely replace the original RawValues of Addon. `merge`: Add or update the corresponding parameters in the original RawValues of Addon according to the new RawValues. Only valid in update addon process.

## Attributes Reference

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/kubernetes_addon_config.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The following arguments are supported:
* `cluster_id` - (Required, String, ForceNew) ID of cluster.
* `addon_version` - (Optional, String) Version of addon.
* `raw_values` - (Optional, String) Params of addon, base64 encoded json format.
* `update_strategy` - (Optional, String) The update strategy of Addon parameters. Valid values are: `replace` and `merge`. The default value is merge, which is compatible with the old version API. `replace`: Use the new RawValues to completely replace the original RawValues of Addon. `merge`: Add or update the corresponding parameters in the original RawValues of Addon according to the new RawValues. Only valid in update addon process.

## Attributes Reference

Expand Down
Loading