Skip to content

Commit 460454d

Browse files
authored
Feat/cos bucket domain certificate (#1258)
* support tmp promethus config * modified according to heller's comment. * add ut * save the tf resource to tfstate locally instead of call the read method * Revised the spec and ut for the name rule about PrometheusConfigItem.Name field. * update the ut * change ut case name * update cos-go-sdk-v5 v0.7.38 * suppport cosBucketDomainCertificate * fix the test case * adjust the name of SslCertificates test case in order to daily automatic test Co-authored-by: nickyinluo <nickyinluo@tencent.com>
1 parent 7793dca commit 460454d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+9813
-793
lines changed

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ require (
1717
github.com/katbyte/terrafmt v0.2.0
1818
github.com/mattn/go-colorable v0.1.6 // indirect
1919
github.com/mitchellh/go-homedir v1.1.0
20-
github.com/mozillazg/go-httpheader v0.3.0 // indirect
20+
github.com/mitchellh/mapstructure v1.5.0 // indirect
21+
github.com/mozillazg/go-httpheader v0.3.1 // indirect
2122
github.com/pkg/errors v0.9.1
2223
github.com/stretchr/testify v1.5.1
2324
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/antiddos v1.0.358
@@ -65,7 +66,7 @@ require (
6566
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199
6667
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.479
6768
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199
68-
github.com/tencentyun/cos-go-sdk-v5 v0.7.33
69+
github.com/tencentyun/cos-go-sdk-v5 v0.7.38
6970
github.com/yangwenmai/ratelimit v0.0.0-20180104140304-44221c2292e1
7071
github.com/zclconf/go-cty v1.4.2 // indirect
7172
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ github.com/bsm/go-vlq v0.0.0-20150828105119-ec6e8d4f5f4e/go.mod h1:N+BjUcTjSxc2m
5858
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
5959
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
6060
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
61+
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
62+
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
6163
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
6264
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
6365
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@@ -329,13 +331,18 @@ github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9
329331
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
330332
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
331333
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
334+
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
335+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
336+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
332337
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
333338
github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE=
334339
github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
335340
github.com/mozilla/tls-observatory v0.0.0-20200317151703-4fa42e1c2dee/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
336341
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
337342
github.com/mozillazg/go-httpheader v0.3.0 h1:3brX5z8HTH+0RrNA1362Rc3HsaxyWEKtGY45YrhuINM=
338343
github.com/mozillazg/go-httpheader v0.3.0/go.mod h1:PuT8h0pw6efvp8ZeUec1Rs7dwjK08bt6gKSReGMqtdA=
344+
github.com/mozillazg/go-httpheader v0.3.1 h1:IRP+HFrMX2SlwY9riuio7raffXUpzAosHtZu25BSJok=
345+
github.com/mozillazg/go-httpheader v0.3.1/go.mod h1:PuT8h0pw6efvp8ZeUec1Rs7dwjK08bt6gKSReGMqtdA=
339346
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
340347
github.com/nakabonne/nestif v0.3.0 h1:+yOViDGhg8ygGrmII72nV9B/zGxY188TYpfolntsaPw=
341348
github.com/nakabonne/nestif v0.3.0/go.mod h1:dI314BppzXjJ4HsCnbo7XzrJHPszZsjnk5wEBSYHI2c=
@@ -547,6 +554,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 h1:hMBLtiJ
547554
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199/go.mod h1:nnY91/H3j/Gu7V/oCA6Zeg8T5D3q36EUdBh4EjmHwqY=
548555
github.com/tencentyun/cos-go-sdk-v5 v0.7.33 h1:5jmJU7U/1nf/7ZPDkrUL8KlF1oDUzTHsdtLNY6x0hq4=
549556
github.com/tencentyun/cos-go-sdk-v5 v0.7.33/go.mod h1:4E4+bQ2gBVJcgEC9Cufwylio4mXOct2iu05WjgEBx1o=
557+
github.com/tencentyun/cos-go-sdk-v5 v0.7.38 h1:EsMD39fDk5GRD8ouOcHG5MAb0CIT0ndDm6kZgSAYuBg=
558+
github.com/tencentyun/cos-go-sdk-v5 v0.7.38/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw=
550559
github.com/tetafro/godot v0.3.7 h1:+mecr7RKrUKB5UQ1gwqEMn13sDKTyDR8KNIquB9mm+8=
551560
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
552561
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=

tencentcloud/basic_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ data "tencentcloud_vpn_connections" "conns" {
4343
}
4444
`
4545

46+
//cos
47+
const (
48+
defaultCosCertificateName = "keep-cos-domain-cert"
49+
defaultCosCertificateBucketPrefix = "keep-cert-test"
50+
)
51+
4652
// clb
4753
const (
4854
defaultSshCertificate = "vYSQkJ3K"

tencentcloud/data_source_tc_ssl_certificates.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func dataSourceTencentCloudSslCertificates() *schema.Resource {
8080
Computed: true,
8181
Description: "Content of the SSL certificate.",
8282
},
83+
"key": {
84+
Type: schema.TypeString,
85+
Computed: true,
86+
Description: "Key of the SSL certificate.",
87+
},
8388
"product_zh_name": {
8489
Type: schema.TypeString,
8590
Computed: true,
@@ -216,6 +221,9 @@ func dataSourceTencentCloudSslCertificatesRead(d *schema.ResourceData, m interfa
216221

217222
if describeResponse != nil && describeResponse.Response != nil {
218223
m["cert"] = *describeResponse.Response.CertificatePublicKey
224+
if describeResponse.Response.CertificatePrivateKey != nil {
225+
m["key"] = *describeResponse.Response.CertificatePrivateKey
226+
}
219227
}
220228

221229
certificates = append(certificates, m)

tencentcloud/data_source_tc_ssl_certificates_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
99
)
1010

11-
func TestAccDataSourceTencentCloudSslCertificates_basic(t *testing.T) {
11+
func TestAccTencentCloudSslCertificatesDataSource_basic(t *testing.T) {
1212
t.Parallel()
1313
resource.Test(t, resource.TestCase{
1414
PreCheck: func() { testAccPreCheck(t) },
@@ -20,7 +20,7 @@ func TestAccDataSourceTencentCloudSslCertificates_basic(t *testing.T) {
2020
testAccCheckTencentCloudDataSourceID("data.tencentcloud_ssl_certificates.foo"),
2121
resource.TestMatchResourceAttr("data.tencentcloud_ssl_certificates.foo", "certificates.#", regexp.MustCompile(`^[1-9]\d*$`)),
2222
resource.TestCheckResourceAttrSet("data.tencentcloud_ssl_certificates.foo", "certificates.0.id"),
23-
resource.TestCheckResourceAttr("data.tencentcloud_ssl_certificates.foo", "certificates.0.name", "ci-test-ssl-ca"),
23+
resource.TestCheckResourceAttr("data.tencentcloud_ssl_certificates.foo", "certificates.0.name", "keep-ssl-ca"),
2424
resource.TestCheckResourceAttrSet("data.tencentcloud_ssl_certificates.foo", "certificates.0.type"),
2525
resource.TestCheckResourceAttrSet("data.tencentcloud_ssl_certificates.foo", "certificates.0.project_id"),
2626
resource.TestCheckResourceAttrSet("data.tencentcloud_ssl_certificates.foo", "certificates.0.cert"),
@@ -36,7 +36,7 @@ func TestAccDataSourceTencentCloudSslCertificates_basic(t *testing.T) {
3636
})
3737
}
3838

39-
func TestAccDataSourceTencentCloudSslCertificates_type(t *testing.T) {
39+
func TestAccTencentCloudSslCertificatesDataSource_type(t *testing.T) {
4040
t.Parallel()
4141
resource.Test(t, resource.TestCase{
4242
PreCheck: func() { testAccPreCheck(t) },
@@ -64,7 +64,7 @@ func TestAccDataSourceTencentCloudSslCertificates_type(t *testing.T) {
6464
})
6565
}
6666

67-
func TestAccDataSourceTencentCloudSslCertificates_id(t *testing.T) {
67+
func TestAccTencentCloudSslCertificatesDataSource_id(t *testing.T) {
6868
t.Parallel()
6969
resource.Test(t, resource.TestCase{
7070
PreCheck: func() { testAccPreCheck(t) },
@@ -97,7 +97,7 @@ var TestAccDataSourceTencentCloudSslCertificatesBasic = fmt.Sprintf(`
9797
resource "tencentcloud_ssl_certificate" "foo" {
9898
type = "CA"
9999
cert = "%s"
100-
name = "ci-test-ssl-ca"
100+
name = "keep-ssl-ca"
101101
}
102102
103103
data "tencentcloud_ssl_certificates" "foo" {
@@ -109,7 +109,7 @@ var TestAccDataSourceTencentCloudSslCertificatesType = fmt.Sprintf(`
109109
resource "tencentcloud_ssl_certificate" "foo" {
110110
type = "CA"
111111
cert = "%s"
112-
name = "ci-test-ssl-ca"
112+
name = "keep-ssl-ca"
113113
}
114114
115115
data "tencentcloud_ssl_certificates" "foo" {
@@ -121,7 +121,7 @@ var TestAccDataSourceTencentCloudSslCertificatesId = fmt.Sprintf(`
121121
resource "tencentcloud_ssl_certificate" "foo" {
122122
type = "CA"
123123
cert = "%s"
124-
name = "ci-test-ssl-ca"
124+
name = "keep-ssl-ca"
125125
}
126126
127127
data "tencentcloud_ssl_certificates" "foo" {

0 commit comments

Comments
 (0)