Skip to content

Commit

Permalink
resource/alicloud_nlb_listener_additional_certificate_attachment: ref…
Browse files Browse the repository at this point in the history
…actoring implement and fix testcase.
  • Loading branch information
ChenHanZhang committed Dec 25, 2024
1 parent 9ec4d89 commit 6b19f7d
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,16 @@ func resourceAliCloudNlbListenerAdditionalCertificateAttachmentCreate(d *schema.
wait := incrementalWait(3*time.Second, 5*time.Second)
err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2022-04-30"), StringPointer("AK"), query, request, &runtime)
request["ClientToken"] = buildClientToken(action)

if err != nil {
if NeedRetry(err) {
wait()
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})
addDebug(action, response, request)

if err != nil {
return WrapErrorf(err, DefaultErrorMsg, "alicloud_nlb_listener_additional_certificate_attachment", action, AlibabaCloudSdkGoERROR)
Expand Down Expand Up @@ -118,8 +116,13 @@ func resourceAliCloudNlbListenerAdditionalCertificateAttachmentRead(d *schema.Re
return WrapError(err)
}

d.Set("status", objectRaw["Status"])
d.Set("certificate_id", objectRaw["CertificateId"])
if objectRaw["Status"] != nil {
d.Set("status", objectRaw["Status"])
}
if objectRaw["CertificateId"] != nil {
d.Set("certificate_id", objectRaw["CertificateId"])
}

parts := strings.Split(d.Id(), ":")
d.Set("listener_id", parts[0])

Expand Down Expand Up @@ -147,7 +150,6 @@ func resourceAliCloudNlbListenerAdditionalCertificateAttachmentDelete(d *schema.
request["ListenerId"] = parts[0]
request["AdditionalCertificateIds.1"] = parts[1]
request["RegionId"] = client.RegionId

request["ClientToken"] = buildClientToken(action)

if v, ok := d.GetOkExists("dry_run"); ok {
Expand All @@ -167,21 +169,22 @@ func resourceAliCloudNlbListenerAdditionalCertificateAttachmentDelete(d *schema.
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})
addDebug(action, response, request)

if err != nil {
if IsExpectedErrors(err, []string{"ResourceNotFound.listener", "ResourceNotFound.loadbalancer"}) {
if IsExpectedErrors(err, []string{"ResourceNotFound.listener", "ResourceNotFound.loadbalancer"}) || NotFoundError(err) {
return nil
}
return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR)
}

nlbServiceV2 := NlbServiceV2{client}
stateConf := BuildStateConf([]string{}, []string{"Succeeded"}, d.Timeout(schema.TimeoutCreate), 5*time.Second, nlbServiceV2.DescribeAsyncNlbListenerAdditionalCertificateAttachmentStateRefreshFunc(d, response, "$.Status", []string{}))
if _, err := stateConf.WaitForState(); err != nil {
return WrapErrorf(err, IdMsg, d.Id())
stateConf := BuildStateConf([]string{}, []string{"Succeeded"}, d.Timeout(schema.TimeoutDelete), 5*time.Second, nlbServiceV2.DescribeAsyncNlbListenerAdditionalCertificateAttachmentStateRefreshFunc(d, response, "$.Status", []string{}))
if jobDetail, err := stateConf.WaitForState(); err != nil {
return WrapErrorf(err, IdMsg, d.Id(), jobDetail)
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,43 +115,56 @@ resource "alicloud_nlb_server_group" "create_sg" {
resource "alicloud_ssl_certificates_service_certificate" "ssl0" {
cert = <<EOF
-----BEGIN CERTIFICATE-----
MIIDRjCCAq+gAwIBAgIJAJn3ox4K13PoMA0GCSqGSIb3DQEBBQUAMHYxCzAJBgNV
BAYTAkNOMQswCQYDVQQIEwJCSjELMAkGA1UEBxMCQkoxDDAKBgNVBAoTA0FMSTEP
MA0GA1UECxMGQUxJWVVOMQ0wCwYDVQQDEwR0ZXN0MR8wHQYJKoZIhvcNAQkBFhB0
ZXN0QGhvdG1haWwuY29tMB4XDTE0MTEyNDA2MDQyNVoXDTI0MTEyMTA2MDQyNVow
djELMAkGA1UEBhMCQ04xCzAJBgNVBAgTAkJKMQswCQYDVQQHEwJCSjEMMAoGA1UE
ChM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QDj7yRa9Yekgff2Ati7ny
pQytSbu/8abzfvHNwmKU6HWoEiKaXSdCyHNIaG8BCnwlilxt44k+YifHftlO9dSi
DkS3AoGAYmF++8uEvQot5Yma4GraY+7ZyfWNLwClsOsrN2g19Vycg16fJk0olwDx
2kRWKqNn99HJJwiLie1nvsDRJLbmzmI91Pttpu/EYFDJ8OYQOr1OhhPwwTygf+7S
1o2RTXu3gKNG6fxOtHFatws3IzvovOASYyJR5XP2sIJURLOrSN0=
-----END RSA PRIVATE KEY-----
EOF
}
Expand All @@ -168,43 +181,56 @@ resource "alicloud_nlb_listener" "create_listener" {
resource "alicloud_ssl_certificates_service_certificate" "ssl" {
cert = <<EOF
-----BEGIN CERTIFICATE-----
MIIDRjCCAq+gAwIBAgIJAJn3ox4K13PoMA0GCSqGSIb3DQEBBQUAMHYxCzAJBgNV
BAYTAkNOMQswCQYDVQQIEwJCSjELMAkGA1UEBxMCQkoxDDAKBgNVBAoTA0FMSTEP
MA0GA1UECxMGQUxJWVVOMQ0wCwYDVQQDEwR0ZXN0MR8wHQYJKoZIhvcNAQkBFhB0
ZXN0QGhvdG1haWwuY29tMB4XDTE0MTEyNDA2MDQyNVoXDTI0MTEyMTA2MDQyNVow
djELMAkGA1UEBhMCQ04xCzAJBgNVBAgTAkJKMQswCQYDVQQHEwJCSjEMMAoGA1UE
ChMDQUxJMQ8wDQYDVQQLEwZBTElZVU4xDTALBgNVBAMTBHRlc3QxHzAdBgkqhkiG
9w0BCQEWEHRlc3RAaG90bWFpbC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ
AoGBAM7SS3e9+Nj0HKAsRuIDNSsS3UK6b+62YQb2uuhKrp1HMrOx61WSDR2qkAnB
coG00Uz38EE+9DLYNUVQBK7aSgLP5M1Ak4wr4GqGyCgjejzzh3DshUzLCCy2rook
KOyRTlPX+Q5l7rE1fcSNzgepcae5i2sE1XXXzLRIDIvQxcspAgMBAAGjgdswgdgw
HQYDVR0OBBYEFBdy+OuM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P2ynRTEN77+FUZkTvmxmSPoIfNTycDPRr4aUwVHV2d5FHPn
d1MdjSoUPbHdOLfynwXqTz9OlvMSUDrBvs6k5ripGY9qvh9PrOdj7zLXVRQXUuOR
YwoVHKECgYEA1NzNGifjW5cdcbkzc86QA9TM7yAyBmgnopzlm+dFIhxtJmydxN4V
820x1Lkfe2vLCyYQ6fcEKAtjC9qdw+E2uzHAbtvnR4JseF3z1D82xw3MgGT9l3zc
mMrgKmdCGGLWi6hboylX+2GBMVl2R0aRZrZje67jZcDXd06mlvW257ECgYEA0Vv1
X3Ubn8XA3AA1ybem8fWNwEXfcYP1lJq0cX1gUXlpQvxWN61//aFZUCJZw5cEPArQ
rEqhT81VCqXGO/by6D3fJD+4P8D6v6szJK2AGvXkZMfnJwAbHcOyGlxMin1CTJss
ZID0XI9xmbedm7Wi40+qXz8q4rs25kft9YjfzMsCgYBSPfE8vtaYJ52nt7+Kae+4
mzqG1XCeixVtPaN1BfjvAf6mDucyDgB7KeBL6S6ht/ceGpoEW30On7+n79JuwRAt
aT6JVotYVKrmIp63jajzZYByxxI3unVcz12m5HhkBaQRF344XxvwMy8ASyloxnod
LjDns52GTeix3wB8aPk/MQKBgGOQRwXpjISUKB64HtxacZN6ArqgwB2c8uqEFDIw
vOCiS7Pmix4ZbdfxpqbcXzIMHKBtSEXXjBWGgd35bmfQDj7yRa9Yekgff2Ati7ny
pQytSbu/8abzfvHNwmKU6HWoEiKaXSdCyHNIaG8BCnwlilxt44k+YifHftlO9dSi
DkS3AoGAYmF++8uEvQot5Yma4GraY+7ZyfWNLwClsOsrN2g19Vycg16fJk0olwDx
2kRWKqNn99HJJwiLie1nvsDRJLbmzmI91Pttpu/EYFDJ8OYQOr1OhhPwwTygf+7S
1o2RTXu3gKNG6fxOtHFatws3IzvovOASYyJR5XP2sIJURLOrSN0=
-----END RSA PRIVATE KEY-----
EOF
}
Expand Down
31 changes: 22 additions & 9 deletions alicloud/service_alicloud_nlb_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ func (s *NlbServiceV2) DescribeNlbListenerAdditionalCertificateAttachment(id str
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})

addDebug(action, response, request)
if err != nil {
return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR)
}
Expand All @@ -148,7 +147,7 @@ func (s *NlbServiceV2) DescribeNlbListenerAdditionalCertificateAttachment(id str
result, _ := v.([]interface{})
for _, v := range result {
item := v.(map[string]interface{})
if item["CertificateId"] != parts[1] {
if fmt.Sprint(item["CertificateId"]) != parts[1] {
continue
}
return item, nil
Expand All @@ -169,6 +168,13 @@ func (s *NlbServiceV2) NlbListenerAdditionalCertificateAttachmentStateRefreshFun
v, err := jsonpath.Get(field, object)
currentStatus := fmt.Sprint(v)

if strings.HasPrefix(field, "#") {
v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object)
if v != nil {
currentStatus = "#CHECKSET"
}
}

for _, failState := range failStates {
if currentStatus == failState {
return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus))
Expand All @@ -181,7 +187,6 @@ func (s *NlbServiceV2) NlbListenerAdditionalCertificateAttachmentStateRefreshFun
func (s *NlbServiceV2) DescribeAsyncGetJobStatus(d *schema.ResourceData, res map[string]interface{}) (object map[string]interface{}, err error) {
client := s.client
id := d.Id()
taskId, err := jsonpath.Get("$.JobId", res)
var request map[string]interface{}
var response map[string]interface{}
var query map[string]interface{}
Expand All @@ -196,9 +201,9 @@ func (s *NlbServiceV2) DescribeAsyncGetJobStatus(d *schema.ResourceData, res map
}
request = make(map[string]interface{})
query = make(map[string]interface{})
query["JobId"], err = jsonpath.Get("$.JobId", res)

request["ClientToken"] = buildClientToken(action)
request["JobId"] = taskId

runtime := util.RuntimeOptions{}
runtime.SetAutoretry(true)
Expand All @@ -214,12 +219,11 @@ func (s *NlbServiceV2) DescribeAsyncGetJobStatus(d *schema.ResourceData, res map
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})

addDebug(action, response, request)
if err != nil {
return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR)
return response, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR)
}

return response, nil
Expand All @@ -232,14 +236,23 @@ func (s *NlbServiceV2) DescribeAsyncNlbListenerAdditionalCertificateAttachmentSt
if NotFoundError(err) {
return object, "", nil
}
return nil, "", WrapError(err)
}

v, err := jsonpath.Get(field, object)
currentStatus := fmt.Sprint(v)

if strings.HasPrefix(field, "#") {
v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object)
if v != nil {
currentStatus = "#CHECKSET"
}
}

for _, failState := range failStates {
if currentStatus == failState {
if _err, ok := object["error"]; ok {
return _err, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus))
}
return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus))
}
}
Expand Down
Loading

0 comments on commit 6b19f7d

Please sign in to comment.