Skip to content

Commit fb29f9a

Browse files
committed
feat(cci): add datasource cci v2 namespaces
1 parent 4bc32ef commit fb29f9a

File tree

4 files changed

+495
-1
lines changed

4 files changed

+495
-1
lines changed

docs/data-sources/cciv2_namespaces.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
subcategory: "Cloud Container Instance (CCI)"
3+
layout: "huaweicloud"
4+
page_title: "HuaweiCloud: huaweicloud_cciv2_namespaces"
5+
description: |-
6+
Use this data source to get the list of CCI namespaces within HuaweiCloud.
7+
---
8+
9+
# huaweicloud_cciv2_namespaces
10+
11+
Use this data source to get the list of CCI namespaces within HuaweiCloud.
12+
13+
## Example Usage
14+
15+
```hcl
16+
variable "namespace_name" {}
17+
18+
data "huaweicloud_cciv2_namespaces" "test" {
19+
name = var.namespace_name
20+
}
21+
```
22+
23+
## Argument Reference
24+
25+
The following arguments are supported:
26+
27+
* `region` - (Optional, String) Specifies the region in which to query the data source.
28+
If omitted, the provider-level region will be used.
29+
30+
* `name` - (Optional, String) Specifies the name of the namespace.
31+
32+
## Attribute Reference
33+
34+
In addition to all arguments above, the following attributes are exported:
35+
36+
* `id` - The data source ID.
37+
38+
* `namespaces` - The CCI namespaces.
39+
The [namespaces](#attrblock_namespaces) structure is documented below.
40+
41+
<a name="attrblock_namespaces"></a>
42+
The `namespaces` block supports:
43+
44+
* `annotations` - The annotations of the namespace.
45+
46+
* `api_version` - The API version of the namespace.
47+
48+
* `cluster_name` - The cluster name of the namespace.
49+
50+
* `creation_timestamp` - The creation timestamp of the namespace.
51+
52+
* `deletion_grace_period_seconds` - The deletion grace period seconds of the namespace.
53+
54+
* `deletion_timestamp` - The deletion timestamp of the namespace.
55+
56+
* `finalizers` - The finalizers of the namespace.
57+
58+
* `generate_name` - The generate name of the namespace.
59+
60+
* `generation` - The generation of the namespace.
61+
62+
* `kind` - The kind of the namespace.
63+
64+
* `labels` - The labels of the namespace.
65+
66+
* `managed_fields` - The managed fields of the namespace.
67+
The [managed_fields](#attrblock_namespaces_managed_fields) structure is documented below.
68+
69+
* `owner_references` - The owner references of the namespace.
70+
The [owner_references](#attrblock_namespaces_owner_references) structure is documented below.
71+
72+
* `resource_version` - The resource version of the namespace.
73+
74+
* `self_link` - The self link of the namespace.
75+
76+
* `status` - The status of the namespace.
77+
78+
* `uid` - The uid of the namespace.
79+
80+
<a name="attrblock_namespaces_managed_fields"></a>
81+
The `managed_fields` block supports:
82+
83+
* `api_version` - The API version of the managed fields.
84+
85+
* `fields_type` - The fields type of the managed fields.
86+
87+
* `fields_v1` - The fields v1 of the managed fields.
88+
89+
* `manager` - The manager of the managed fields.
90+
91+
* `operation` - The operation of the managed fields.
92+
93+
* `time` - The time of the managed fields.
94+
95+
<a name="attrblock_namespaces_owner_references"></a>
96+
The `owner_references` block supports:
97+
98+
* `api_version` - The API version of the owner references.
99+
100+
* `block_owner_deletion` - The block owner deletion of the owner references.
101+
102+
* `controller` - The controller of the owner references.
103+
104+
* `kind` - The kind of the owner references.
105+
106+
* `name` - The name of the owner references.
107+
108+
* `uid` - The uid of the owner references.

huaweicloud/provider.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ func Provider() *schema.Provider {
555555
"huaweicloud_cce_charts": cce.DataSourceCCECharts(),
556556
"huaweicloud_cce_cluster_configurations": cce.DataSourceClusterConfigurations(),
557557

558-
"huaweicloud_cci_namespaces": cci.DataSourceCciNamespaces(),
558+
"huaweicloud_cci_namespaces": cci.DataSourceCciNamespaces(),
559+
"huaweicloud_cciv2_namespaces": cci.DataSourceV2Namespaces(),
559560

560561
"huaweicloud_ccm_certificates": ccm.DataSourceCertificates(),
561562
"huaweicloud_ccm_certificate_export": ccm.DataSourceCertificateExport(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package cci
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
9+
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
10+
)
11+
12+
func TestAccV2Namespaces_basic(t *testing.T) {
13+
dataSourceName := "data.huaweicloud_cciv2_namespaces.test"
14+
rName := acceptance.RandomAccResourceNameWithDash()
15+
16+
resource.ParallelTest(t, resource.TestCase{
17+
PreCheck: func() { acceptance.TestAccPreCheck(t) },
18+
ProviderFactories: acceptance.TestAccProviderFactories,
19+
Steps: []resource.TestStep{
20+
{
21+
Config: testAccV2Namespaces_basic(rName),
22+
Check: resource.ComposeTestCheckFunc(
23+
resource.TestCheckResourceAttr(dataSourceName, "namespaces.#", "1"),
24+
),
25+
},
26+
},
27+
})
28+
}
29+
30+
func testAccV2Namespaces_basic(rName string) string {
31+
return fmt.Sprintf(`
32+
%s
33+
34+
data "huaweicloud_cci_namespaces" "test" {
35+
depends_on = [huaweicloud_cci_network.test]
36+
37+
name = "%s"
38+
}
39+
`, testAccDataCciNamespaces_base(rName), rName)
40+
}

0 commit comments

Comments
 (0)