-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cce): add data_source autopilot cluster certificate (#6074)
- Loading branch information
1 parent
18728d3
commit 1172c45
Showing
5 changed files
with
431 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
--- | ||
subcategory: "Cloud Container Engine Autopilot (CCE Autopilot)" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCloud: huaweicloud_cce_autopilot_cluster_certificate" | ||
description: |- | ||
Use this data source to get the certificate of a CCE Autopilot cluster within HuaweiCloud. | ||
--- | ||
|
||
# huaweicloud_cce_autopilot_cluster_certificate | ||
|
||
Use this data source to get the certificate of a CCE Autopilot cluster within HuaweiCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "cluster_id" {} | ||
data "huaweicloud_cce_autopilot_cluster_certificate" "test" { | ||
cluster_id = var.cluster_id | ||
duration = 30 | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to query the resource. | ||
If omitted, the provider-level region will be used. | ||
|
||
* `cluster_id` - (Required, String) Specifies the cluster ID to which the cluster certificate belongs. | ||
|
||
* `duration` - (Required, Int) Specifies the duration of the cluster certificate. | ||
The unit is days. The valid value in [1, 1825]. If the input value is -1, | ||
it will use the maximum 1825 as `duration` value. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `kube_config_raw` - Raw Kubernetes config to be used by kubectl and other compatible tools. | ||
|
||
* `clusters` - The clusters information of the cluster certificate. | ||
|
||
The [clusters](#clusters_struct) structure is documented below. | ||
|
||
* `users` - The users information of cluster the certificate. | ||
|
||
The [users](#users_struct) structure is documented below. | ||
|
||
* `contexts` - The contexts information of the cluster certificate. | ||
|
||
The [contexts](#contexts_struct) structure is documented below. | ||
|
||
* `current_context` - The current context of the cluster certificate. | ||
|
||
<a name="clusters_struct"></a> | ||
The `clusters` block supports: | ||
|
||
* `name` - The cluster name of the cluster certificate. | ||
|
||
* `cluster` - The cluster information. | ||
|
||
The [cluster](#clusters_cluster_struct) structure is documented below. | ||
|
||
<a name="clusters_cluster_struct"></a> | ||
The `cluster` block supports: | ||
|
||
* `server` - The server address of the cluster certificate. | ||
|
||
* `certificate_authority_data` - The certificate authority data of the cluster certificate. | ||
|
||
* `insecure_skip_tls_verify` - Whether insecure skip tls verify of the cluster certificate. | ||
|
||
<a name="users_struct"></a> | ||
The `users` block supports: | ||
|
||
* `name` - The user name of the cluster certificate. | ||
The value is fixed to `user`. | ||
|
||
* `user` - The user information. | ||
|
||
The [user](#users_user_struct) structure is documented below. | ||
|
||
<a name="users_user_struct"></a> | ||
The `user` block supports: | ||
|
||
* `client_certificate_data` - The client certificate data of the cluster certificate. | ||
|
||
* `client_key_data` - The client key data of the cluster certificate. | ||
|
||
<a name="contexts_struct"></a> | ||
The `contexts` block supports: | ||
|
||
* `name` - The context name of the cluster certificate. | ||
|
||
* `context` - The user information. | ||
|
||
The [context](#contexts_context_struct) structure is documented below. | ||
|
||
<a name="contexts_context_struct"></a> | ||
The `context` block supports: | ||
|
||
* `cluster` - The context cluster of the cluster certificate. | ||
|
||
* `user` - The context user of the cluster certificate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...acceptance/cceautopilot/data_source_huaweicloud_cce_autopilot_cluster_certificate_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cceautopilot | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccDataSourceCceAutopilotClusterCertificate_basic(t *testing.T) { | ||
dataSource := "data.huaweicloud_cce_autopilot_cluster_certificate.test" | ||
rName := acceptance.RandomAccResourceNameWithDash() | ||
dc := acceptance.InitDataSourceCheck(dataSource) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDataSourceDataSourceCceAutopilotClusterCertificate_basic(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestCheckResourceAttr(dataSource, "duration", "30"), | ||
resource.TestCheckResourceAttr(dataSource, "clusters.#", "2"), | ||
resource.TestCheckResourceAttr(dataSource, "users.#", "1"), | ||
resource.TestCheckResourceAttr(dataSource, "contexts.#", "2"), | ||
resource.TestCheckResourceAttrSet(dataSource, "current_context"), | ||
resource.TestCheckResourceAttrSet(dataSource, "kube_config_raw"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDataSourceDataSourceCceAutopilotClusterCertificate_basic(name string) string { | ||
return fmt.Sprintf(` | ||
%[1]s | ||
data "huaweicloud_cce_autopilot_cluster_certificate" "test" { | ||
cluster_id = huaweicloud_cce_autopilot_cluster.test.id | ||
duration = 30 | ||
} | ||
`, testAccCluster_basic(name)) | ||
} |
Oops, something went wrong.