Skip to content

Commit eb46600

Browse files
authored
fix(lb): throw a warning when certificate is in error state (#2063)
* fix(lb): throw a warning when certificate is in error state * update cassette * test * fix
1 parent 37f7395 commit eb46600

File tree

2 files changed

+454
-819
lines changed

2 files changed

+454
-819
lines changed

scaleway/resource_lb_certificate.go

+14-16
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,6 @@ func resourceScalewayLbCertificateRead(ctx context.Context, d *schema.ResourceDa
193193
return diag.FromErr(err)
194194
}
195195

196-
// check if cert is on error state
197-
if certificate.Status == lbSDK.CertificateStatusError {
198-
return diag.Diagnostics{
199-
diag.Diagnostic{
200-
Severity: diag.Error,
201-
Summary: fmt.Sprintf("certificate %s with error state", certificate.ID),
202-
},
203-
}
204-
}
205-
206-
_, err = waitForLBCertificate(ctx, lbAPI, zone, certificate.ID, d.Timeout(schema.TimeoutRead))
207-
if err != nil {
208-
return diag.FromErr(err)
209-
}
210-
211196
_ = d.Set("lb_id", newZonedIDString(zone, certificate.LB.ID))
212197
_ = d.Set("name", certificate.Name)
213198
_ = d.Set("common_name", certificate.CommonName)
@@ -217,7 +202,20 @@ func resourceScalewayLbCertificateRead(ctx context.Context, d *schema.ResourceDa
217202
_ = d.Set("not_valid_after", flattenTime(certificate.NotValidAfter))
218203
_ = d.Set("status", certificate.Status)
219204

220-
return nil
205+
diags := diag.Diagnostics(nil)
206+
207+
if certificate.Status == lbSDK.CertificateStatusError {
208+
errDetails := ""
209+
if certificate.StatusDetails != nil {
210+
errDetails = *certificate.StatusDetails
211+
}
212+
diags = append(diags, diag.Diagnostic{
213+
Severity: diag.Warning,
214+
Summary: fmt.Sprintf("certificate %s with error state", certificate.ID),
215+
Detail: errDetails,
216+
})
217+
}
218+
return diags
221219
}
222220

223221
func resourceScalewayLbCertificateUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {

0 commit comments

Comments
 (0)