Skip to content

Commit 0971067

Browse files
authored
feat(tke): [120409794] support cluster_os field to update and adjust its set logic (#2918)
* feat(tke): [120409794] 1.cluster_os support modify. 2.adjust cluster_os set logic * support cluster_os update * add changelog and doc * support cidr 11 prefix
1 parent 48465d5 commit 0971067

File tree

10 files changed

+192
-10
lines changed

10 files changed

+192
-10
lines changed

.changelog/2918.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_kubernetes_cluster: support `cluster_os` field to update and adjust its set logic
3+
```

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ require (
4646
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.984
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544
4848
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.970
49-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1027
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1031
5050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1014
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
@@ -91,7 +91,7 @@ require (
9191
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq v1.0.955
9292
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578
9393
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.1013
94-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1027
94+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031
9595
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.947
9696
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857
9797
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,10 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1025 h1:VBC
941941
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1025/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
942942
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1027 h1:4/chUqYM26idp2Rd3pPmsL94RTAwIM5dGXoaskOQ+cM=
943943
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1027/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
944+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1030 h1:kwiUoCkooUgy7iPyhEEbio7WT21kGJUeZ5JeJfb/dYk=
945+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1030/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
946+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1031 h1:3ouglYKE5cwhx2vwICGeW7pAlwyCLnpQd7O0l3hCSTg=
947+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1031/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
944948
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ=
945949
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY=
946950
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
@@ -1051,6 +1055,10 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1025 h1:KQTBLt
10511055
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1025/go.mod h1:WBsBVG3Qb9bupdElk/d/S7xLadGwyBvKF2VikkezhjE=
10521056
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1027 h1:CCbjHzYueJMa6O3aH2zn/Uppp+u7YJSd7oTrtypxGhM=
10531057
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1027/go.mod h1:U0WwaLeMZf4Qx1SGG6TlFBhwlV03BMF5F176G14W9Qc=
1058+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1030 h1:/PpJ0QVuKHaZ3khR17DktATXccHT8761D9bTZwPmrHY=
1059+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1030/go.mod h1:h9iblPtLWJRVlVyFFwYM+3V54B3i1JZq6yxmSVnY49c=
1060+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031 h1:0Ew48YnVO+Sd2U3VrWgV36uRySTF7uOOFJH0Hd4ufhg=
1061+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031/go.mod h1:KcKTYEXZil0FciUtQ75svPL4hZpLYVnemAeW27N3OKY=
10541062
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.947 h1:iZfuU8S86kfqFsAVT/LUApP8L5cpT90hl2wSKiUDVvw=
10551063
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.947/go.mod h1:eAgJ+XUEhffMq79zjpgHoR3PBVcciSg+LuPDC8hLWsE=
10561064
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857 h1:TkJnvSeRSXsRCwOwcwXSvruSK9s/kw8LC3FLeccw+A0=

tencentcloud/services/tke/resource_tc_kubernetes_cluster.go

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tencentcloud/services/tke/resource_tc_kubernetes_cluster_extension.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,11 @@ func resourceTencentCloudKubernetesClusterReadPostHandleResponse0(ctx context.Co
593593
newOs = oldOs
594594
}
595595
_ = d.Set("cluster_os", newOs)
596+
// When ImageId is not empty, cluster_os is ImageId. When ImageId is empty, cluster_os displays ClusterOs
597+
if cluster.ImageId != nil && *cluster.ImageId != "" {
598+
_ = d.Set("cluster_os", *cluster.ImageId)
599+
}
600+
596601
_ = d.Set("tags", clusterInfo.Tags)
597602

598603
_ = d.Set("vpc_cni_type", clusterInfo.VpcCniType)
@@ -1567,16 +1572,16 @@ func clusterCidrValidateFunc(v interface{}, k string) (ws []string, errs []error
15671572
errs = append(errs, fmt.Errorf("%q must be a network segment", k))
15681573
return
15691574
}
1570-
if !strings.HasPrefix(value, "9.") && !strings.HasPrefix(value, "10.") && !strings.HasPrefix(value, "192.168.") && !strings.HasPrefix(value, "172.") {
1571-
errs = append(errs, fmt.Errorf("%q must in 9. | 10. | 192.168. | 172.[16-31]", k))
1575+
if !strings.HasPrefix(value, "9.") && !strings.HasPrefix(value, "10.") && !strings.HasPrefix(value, "11.") && !strings.HasPrefix(value, "192.168.") && !strings.HasPrefix(value, "172.") {
1576+
errs = append(errs, fmt.Errorf("%q must in 9. | 10. | 11. | 192.168. | 172.[16-31]", k))
15721577
return
15731578
}
15741579

15751580
if strings.HasPrefix(value, "172.") {
15761581
nextNo := strings.Split(value, ".")[1]
15771582
no, _ := strconv.ParseInt(nextNo, 10, 64)
15781583
if no < 16 || no > 31 {
1579-
errs = append(errs, fmt.Errorf("%q must in 9.0 | 10. | 192.168. | 172.[16-31]", k))
1584+
errs = append(errs, fmt.Errorf("%q must in 9.0 | 10. | 11. | 192.168. | 172.[16-31]", k))
15801585
return
15811586
}
15821587
}

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/client.go

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525/models.go

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319
11631163
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.970
11641164
## explicit; go 1.14
11651165
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016
1166-
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1027
1166+
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1031
11671167
## explicit; go 1.11
11681168
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common
11691169
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors
@@ -1321,7 +1321,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901
13211321
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc v1.0.998
13221322
## explicit; go 1.14
13231323
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/thpc/v20230321
1324-
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1027
1324+
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.1031
13251325
## explicit; go 1.14
13261326
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525
13271327
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20220501

website/docs/r/kubernetes_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ The following arguments are supported:
846846
* `cluster_max_service_num` - (Optional, Int, ForceNew) The maximum number of services in the cluster. Default is 256. The range is from 32 to 32768. When its power unequal to 2, it will round upward to the closest power of 2.
847847
* `cluster_name` - (Optional, String) Name of the cluster.
848848
* `cluster_os_type` - (Optional, String, ForceNew) Image type of the cluster os, the available values include: 'GENERAL'. Default is 'GENERAL'.
849-
* `cluster_os` - (Optional, String, ForceNew) Cluster operating system, supports setting public images (the field passes the corresponding image Name) and custom images (the field passes the corresponding image ID). For details, please refer to: https://cloud.tencent.com/document/product/457/68289.
849+
* `cluster_os` - (Optional, String) Cluster operating system, supports setting public images (the field passes the corresponding image Name) and custom images (the field passes the corresponding image ID). For details, please refer to: https://cloud.tencent.com/document/product/457/68289.
850850
* `cluster_subnet_id` - (Optional, String, ForceNew) Subnet ID of the cluster, such as: subnet-b3p7d7q5.
851851
* `cluster_version` - (Optional, String) Version of the cluster. Use `tencentcloud_kubernetes_available_cluster_versions` to get the upgradable cluster version.
852852
* `container_runtime` - (Optional, String, ForceNew) Runtime type of the cluster, the available values include: 'docker' and 'containerd'.The Kubernetes v1.24 has removed dockershim, so please use containerd in v1.24 or higher.Default is 'docker'.

0 commit comments

Comments
 (0)