Skip to content

Commit 7ce4149

Browse files
authored
Feat/example tcr (#1974)
* example readjust: tencentcloud_kubernetes_serverless_node_pool * add pre-commit-local * adjust e2e case * update example
1 parent bccdd26 commit 7ce4149

29 files changed

+799
-235
lines changed

tencentcloud/basic_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ variable "cam_user_basic" {
569569

570570
// TCR Service
571571
const defaultTCRInstanceName = "keep-tcr-instance-sh"
572-
const defaultTCRInstanceId = "tcr-800uf6j9"
572+
const defaultTCRInstanceId = "tcr-aoz8mxoz"
573573
const defaultTCRNamespace = "keep-tcr-namespace-sh"
574574
const defaultTCRRepoName = "keep-tcr-repo-sh"
575575
const defaultTCRSSL = "zjUMifFK"

tencentcloud/resource_tc_tcr_create_image_signature_operation.go

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
11
/*
2-
Provides a resource to create a tcr image_signature_operation
2+
Provides a resource to operate a tcr image signature.
33
44
Example Usage
55
66
```hcl
7-
resource "tencentcloud_tcr_create_image_signature_operation" "image_signature_operation" {
8-
registry_id = "tcr-xxx"
9-
namespace_name = "ns"
10-
repository_name = "repo"
11-
image_version = "v1"
7+
resource "tencentcloud_tcr_instance" "example" {
8+
name = "tf-example-tcr"
9+
instance_type = "premium"
10+
tags = {
11+
"createdBy" = "terraform"
12+
}
13+
}
14+
15+
resource "tencentcloud_tcr_namespace" "example" {
16+
instance_id = tencentcloud_tcr_instance.example.id
17+
name = "tf_example_ns"
18+
is_public = true
19+
is_auto_scan = true
20+
is_prevent_vul = true
21+
severity = "medium"
22+
cve_whitelist_items {
23+
cve_id = "cve-xxxxx"
24+
}
25+
}
26+
27+
resource "tencentcloud_tcr_repository" "example" {
28+
instance_id = tencentcloud_tcr_instance.example.id
29+
namespace_name = tencentcloud_tcr_namespace.example.name
30+
name = "test"
31+
brief_desc = "111"
32+
description = "111111111111111111111111111111111111"
33+
}
1234
35+
resource "tencentcloud_tcr_create_image_signature_operation" "example" {
36+
registry_id = tencentcloud_tcr_instance.example.id
37+
namespace_name = tencentcloud_tcr_namespace.example.name
38+
repository_name = tencentcloud_tcr_repository.example.name
39+
image_version = "v1"
1340
}
1441
```
1542

tencentcloud/resource_tc_tcr_customized_domain.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
/*
2-
Provides a resource to create a tcr customized_domain
2+
Provides a resource to create a tcr customized domain
33
44
Example Usage
55
6+
Create a tcr customized domain
7+
68
```hcl
7-
resource "tencentcloud_tcr_customized_domain" "my_domain" {
8-
registry_id = local.tcr_id
9-
domain_name = "www.test.com"
10-
certificate_id = "%s"
9+
resource "tencentcloud_tcr_instance" "example" {
10+
name = "tf-example-tcr"
11+
instance_type = "premium"
12+
tags = {
13+
"createdBy" = "terraform"
14+
}
15+
}
16+
17+
resource "tencentcloud_tcr_customized_domain" "example" {
18+
registry_id = tencentcloud_tcr_instance.example.id
19+
domain_name = "www.test.com"
20+
certificate_id = "your_cert_id"
1121
tags = {
1222
"createdBy" = "terraform"
1323
}

tencentcloud/resource_tc_tcr_delete_image_operation.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
/*
2-
Provides a resource to create a tcr delete_image_operation
2+
Provides a resource to delete the specified tcr image.
33
44
Example Usage
55
6+
To delete the specified image
7+
68
```hcl
7-
resource "tencentcloud_tcr_delete_image_operation" "delete_image_operation" {
8-
registry_id = "tcr-xxx"
9+
resource "tencentcloud_tcr_instance" "example" {
10+
name = "tf-example-tcr"
11+
instance_type = "premium"
12+
tags = {
13+
"createdBy" = "terraform"
14+
}
15+
}
16+
17+
resource "tencentcloud_tcr_namespace" "example" {
18+
instance_id = tencentcloud_tcr_instance.example.id
19+
name = "tf_example_ns"
20+
is_public = true
21+
is_auto_scan = true
22+
is_prevent_vul = true
23+
severity = "medium"
24+
cve_whitelist_items {
25+
cve_id = "cve-xxxxx"
26+
}
27+
}
28+
29+
resource "tencentcloud_tcr_delete_image_operation" "example" {
30+
registry_id = tencentcloud_tcr_instance.example.id
931
repository_name = "repo"
10-
image_version = "v1"
11-
namespace_name = "ns"
32+
image_version = "v1" # the image want to delete
33+
namespace_name = tencentcloud_tcr_namespace.example.name
1234
}
1335
```
14-
1536
*/
1637
package tencentcloud
1738

tencentcloud/resource_tc_tcr_immutable_tag_rule.go

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,91 @@
11
/*
2-
Provides a resource to create a tcr immutable_tag_rule
2+
Provides a resource to create a tcr immutable tag rule.
33
44
Example Usage
55
6+
Create a immutable tag rule with specified tags and exclude specified repositories
7+
68
```hcl
7-
resource "tencentcloud_tcr_immutable_tag_rule" "my_rule" {
8-
registry_id = "%s"
9-
namespace_name = "%s"
9+
resource "tencentcloud_tcr_instance" "example" {
10+
name = "tf-example-tcr"
11+
instance_type = "premium"
12+
delete_bucket = true
13+
}
14+
15+
resource "tencentcloud_tcr_namespace" "example" {
16+
instance_id = tencentcloud_tcr_instance.example.id
17+
name = "tf_example_ns"
18+
is_public = true
19+
is_auto_scan = true
20+
is_prevent_vul = true
21+
severity = "medium"
22+
cve_whitelist_items {
23+
cve_id = "cve-xxxxx"
24+
}
25+
}
26+
27+
resource "tencentcloud_tcr_immutable_tag_rule" "example" {
28+
registry_id = tencentcloud_tcr_instance.example.id
29+
namespace_name = tencentcloud_tcr_namespace.example.name
30+
rule {
31+
repository_pattern = "deprecated_repo" # specify exclude repo
32+
tag_pattern = "**" # all tags
33+
repository_decoration = "repoExcludes"
34+
tag_decoration = "matches"
35+
disabled = false
36+
}
37+
tags = {
38+
"createdBy" = "terraform"
39+
}
40+
}
41+
```
42+
43+
With specified repositories and exclude specified version tag
44+
45+
```hcl
46+
resource "tencentcloud_tcr_immutable_tag_rule" "example" {
47+
registry_id = tencentcloud_tcr_instance.example.id
48+
namespace_name = tencentcloud_tcr_namespace.example.name
49+
rule {
50+
repository_pattern = "**" # all repo
51+
tag_pattern = "v1" # exlude v1 tags
52+
repository_decoration = "repoMatches"
53+
tag_decoration = "excludes"
54+
disabled = false
55+
}
56+
tags = {
57+
"createdBy" = "terraform"
58+
}
59+
}
60+
```
61+
62+
Disabled the specified rule
63+
64+
```hcl
65+
resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_A" {
66+
registry_id = tencentcloud_tcr_instance.example.id
67+
namespace_name = tencentcloud_tcr_namespace.example.name
68+
rule {
69+
repository_pattern = "deprecated_repo" # specify exclude repo
70+
tag_pattern = "**" # all tags
71+
repository_decoration = "repoExcludes"
72+
tag_decoration = "matches"
73+
disabled = false
74+
}
75+
tags = {
76+
"createdBy" = "terraform"
77+
}
78+
}
79+
80+
resource "tencentcloud_tcr_immutable_tag_rule" "example_rule_B" {
81+
registry_id = tencentcloud_tcr_instance.example.id
82+
namespace_name = tencentcloud_tcr_namespace.example.name
1083
rule {
11-
repository_pattern = "**"
12-
tag_pattern = "**"
13-
repository_decoration = "repoMatches"
14-
tag_decoration = "matches"
15-
disabled = false
84+
repository_pattern = "**" # all repo
85+
tag_pattern = "v1" # exlude v1 tags
86+
repository_decoration = "repoMatches"
87+
tag_decoration = "excludes"
88+
disabled = true # disable it
1689
}
1790
tags = {
1891
"createdBy" = "terraform"

tencentcloud/resource_tc_tcr_instance.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@ Use this resource to create tcr instance.
33
44
Example Usage
55
6+
Create a basic tcr instance.
7+
68
```hcl
7-
resource "tencentcloud_tcr_instance" "foo" {
8-
name = "example"
9+
resource "tencentcloud_tcr_instance" "example" {
10+
name = "tf-example-tcr"
911
instance_type = "basic"
1012
1113
tags = {
12-
test = "tf"
14+
"createdBy" = "terraform"
1315
}
1416
}
1517
```
1618
17-
Using public network access whitelist
19+
Create instance with the public network access whitelist.
20+
1821
```hcl
19-
resource "tencentcloud_tcr_instance" "foo" {
20-
name = "example"
22+
resource "tencentcloud_tcr_instance" "example" {
23+
name = "tf-example-tcr"
2124
instance_type = "basic"
2225
open_public_operation = true
2326
security_policy {
@@ -29,12 +32,11 @@ resource "tencentcloud_tcr_instance" "foo" {
2932
}
3033
```
3134
32-
Create with Replications
35+
Create instance with Replications.
3336
3437
```hcl
35-
36-
resource "tencentcloud_tcr_instance" "foo" {
37-
name = "example"
38+
resource "tencentcloud_tcr_instance" "example" {
39+
name = "tf-example-tcr"
3840
instance_type = "premium"
3941
replications {
4042
region_id = var.tcr_region_map["ap-guangzhou"] # 1
@@ -73,7 +75,7 @@ Import
7375
tcr instance can be imported using the id, e.g.
7476
7577
```
76-
$ terraform import tencentcloud_tcr_instance.foo cls-cda1iex1
78+
$ terraform import tencentcloud_tcr_instance.foo instance_id
7779
```
7880
*/
7981
package tencentcloud

0 commit comments

Comments
 (0)