Skip to content

Commit b401ba0

Browse files
authored
Merge pull request #159 from Sherlock-Holo/gaap-fix
Fix gaap nil error
2 parents 60d806d + 3b5dea8 commit b401ba0

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ ENHANCEMENTS:
77
* Resource: `tencentcloud_eip` add optional argument `type`, `anycast_zone`, `internet_service_provider`, etc.
88
* Resource: `tencentcloud_as_scaling_group` add optional argument `tags`.
99

10+
BUG FIXES:
11+
12+
* Data Source: `tencentcloud_gaap_http_domains` set response `certificate_id`, `client_certificate_id`, `realserver_auth`, `basic_auth` and `gaap_auth` default value when they are nil.
13+
* Resource: `tencentcloud_gaap_http_domain` set response `certificate_id`, `client_certificate_id`, `realserver_auth`, `basic_auth` and `gaap_auth` default value when they are nil.
14+
1015
## 1.20.0 (September 24, 2019)
1116

1217
FEATURES:

tencentcloud/data_source_tc_gaap_http_domains.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ package tencentcloud
3434

3535
import (
3636
"context"
37-
"errors"
3837
"log"
3938

4039
"github.com/hashicorp/terraform/helper/schema"
@@ -143,27 +142,27 @@ func dataSourceTencentCloudGaapHttpDomainsRead(d *schema.ResourceData, m interfa
143142
domains := make([]map[string]interface{}, 0, len(domainRules))
144143
for _, dr := range domainRules {
145144
if dr.CertificateId == nil {
146-
return errors.New("domain certificate id is nil")
145+
dr.CertificateId = stringToPointer("default")
147146
}
148147
if dr.ClientCertificateId == nil {
149-
return errors.New("domain client certificate id is nil")
148+
dr.ClientCertificateId = stringToPointer("default")
150149
}
151150
if dr.RealServerAuth == nil {
152-
return errors.New("domain realserver auth is nil")
151+
dr.RealServerAuth = int64ToPointer(0)
153152
}
154153
if dr.BasicAuth == nil {
155-
return errors.New("domain basic auth is nil")
154+
dr.BasicAuth = int64ToPointer(0)
156155
}
157156
if dr.GaapAuth == nil {
158-
return errors.New("domain gaap auth is nil")
157+
dr.GaapAuth = int64ToPointer(0)
159158
}
160159

161160
ids = append(ids, *dr.Domain)
162161

163162
m := map[string]interface{}{
164-
"domain": *dr.Domain,
165-
"certificate_id": *dr.CertificateId,
166-
"client_certificate_id": *dr.ClientCertificateId,
163+
"domain": dr.Domain,
164+
"certificate_id": dr.CertificateId,
165+
"client_certificate_id": dr.ClientCertificateId,
167166
"realserver_auth": *dr.RealServerAuth == 1,
168167
"basic_auth": *dr.BasicAuth == 1,
169168
"gaap_auth": *dr.GaapAuth == 1,

tencentcloud/resource_tc_gaap_http_domain.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,17 @@ func resourceTencentCloudGaapHttpDomainRead(d *schema.ResourceData, m interface{
280280
}
281281

282282
if httpDomain.CertificateId == nil {
283-
return errors.New("domain certificate id is nil")
283+
httpDomain.CertificateId = stringToPointer("default")
284284
}
285285
d.Set("certificate_id", httpDomain.CertificateId)
286286

287287
if httpDomain.ClientCertificateId == nil {
288-
return errors.New("domain client certificate id is nil")
288+
httpDomain.ClientCertificateId = stringToPointer("default")
289289
}
290290
d.Set("client_certificate_id", httpDomain.ClientCertificateId)
291291

292292
if httpDomain.BasicAuth == nil {
293-
return errors.New("domain basic auth is nil")
293+
httpDomain.BasicAuth = int64ToPointer(0)
294294
}
295295
d.Set("basic_auth", *httpDomain.BasicAuth == 1)
296296

@@ -299,7 +299,7 @@ func resourceTencentCloudGaapHttpDomainRead(d *schema.ResourceData, m interface{
299299
}
300300

301301
if httpDomain.RealServerAuth == nil {
302-
return errors.New("domain realserver auth is nil")
302+
httpDomain.RealServerAuth = int64ToPointer(0)
303303
}
304304
d.Set("realserver_auth", *httpDomain.RealServerAuth == 1)
305305

@@ -311,7 +311,7 @@ func resourceTencentCloudGaapHttpDomainRead(d *schema.ResourceData, m interface{
311311
}
312312

313313
if httpDomain.GaapAuth == nil {
314-
return errors.New("domain gaap auth is nil")
314+
httpDomain.GaapAuth = int64ToPointer(0)
315315
}
316316
d.Set("gaap_auth", *httpDomain.GaapAuth == 1)
317317

0 commit comments

Comments
 (0)