Skip to content
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

feat(tke): [119722168] kubernetes_health_check_template datasource #2876

Open
wants to merge 3 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
3 changes: 3 additions & 0 deletions .changelog/2876.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-data-source
tencentcloud_kubernetes_health_check_template
```
2 changes: 1 addition & 1 deletion tencentcloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ func Provider() *schema.Provider {
"tencentcloud_cdc_dedicated_cluster_instance_types": cdc.DataSourceTencentCloudCdcDedicatedClusterInstanceTypes(),
"tencentcloud_cdc_dedicated_cluster_orders": cdc.DataSourceTencentCloudCdcDedicatedClusterOrders(),
"tencentcloud_cdwdoris_instances": cdwdoris.DataSourceTencentCloudCdwdorisInstances(),
"tencentcloud_lite_hbase_instances": emr.DataSourceTencentCloudLiteHbaseInstances()},
"tencentcloud_lite_hbase_instances": emr.DataSourceTencentCloudLiteHbaseInstances(), "tencentcloud_kubernetes_health_check_template": tke.DataSourceTencentCloudKubernetesHealthCheckTemplate()},

ResourcesMap: map[string]*schema.Resource{
"tencentcloud_project": project.ResourceTencentCloudProject(),
Expand Down

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Use this data source to query detailed information of tke kubernetes_health_check_template

Example Usage

```hcl
data "tencentcloud_kubernetes_health_check_template" "kubernetes_health_check_template" {
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package tke
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package tke

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
)

func TestAccTencentCloudKubernetesHealthCheckTemplateDataSource_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() {
tcacctest.AccPreCheck(t)
},
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{{
Config: testAccKubernetesHealthCheckTemplateDataSource,
Check: resource.ComposeTestCheckFunc(resource.AccCheckTencentCloudDataSourceID("data.tencentcloud_kubernetes_health_check_template.kubernetes_health_check_template")),
}},
})
}

const testAccKubernetesHealthCheckTemplateDataSource = `

data "tencentcloud_kubernetes_health_check_template" "kubernetes_health_check_template" {
}
`
29 changes: 29 additions & 0 deletions tencentcloud/services/tke/service_tencentcloud_tke.go
Original file line number Diff line number Diff line change
Expand Up @@ -3655,3 +3655,32 @@ func (me *TkeService) DescribeKubernetesLogConfigById(ctx context.Context, clust
ret = response.Response
return
}

func (me *TkeService) DescribeKubernetesHealthCheckTemplateByFilter(ctx context.Context, param map[string]interface{}) (ret *tke2.DescribeHealthCheckTemplateResponseParams, errRet error) {
var (
logId = tccommon.GetLogId(ctx)
request = tke2.NewDescribeHealthCheckTemplateRequest()
)

defer func() {
if errRet != nil {
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error())
}
}()

ratelimit.Check(request.GetAction())

response, err := me.client.UseTkeV20220501Client().DescribeHealthCheckTemplate(request)
if err != nil {
errRet = err
return
}
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())

if response == nil || response.Response == nil {
return
}

ret = response.Response
return
}
Loading