Skip to content

Commit 7fdd01a

Browse files
committed
use io.ReadAll
1 parent 778d970 commit 7fdd01a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

internal/services/mongodb/instance.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package mongodb
22

33
import (
4-
"bytes"
54
"context"
65
"errors"
76
"fmt"
@@ -472,12 +471,16 @@ func ResourceInstanceRead(ctx context.Context, d *schema.ResourceData, m any) di
472471
InstanceID: ID,
473472
}, scw.WithContext(ctx))
474473

475-
var buf bytes.Buffer
476-
477474
if err == nil && cert != nil {
478-
_, copyErr := io.Copy(&buf, cert.Content)
479-
if copyErr == nil {
480-
_ = d.Set("tls_certificate", buf.String())
475+
certBytes, readErr := io.ReadAll(cert.Content)
476+
if readErr == nil {
477+
_ = d.Set("tls_certificate", string(certBytes))
478+
} else {
479+
diags = append(diags, diag.Diagnostic{
480+
Severity: diag.Warning,
481+
Summary: "Failed to read MongoDB TLS certificate content",
482+
Detail: readErr.Error(),
483+
})
481484
}
482485
}
483486

0 commit comments

Comments
 (0)