From c46132cfe2e2ef5538e727ad55e0a74f7b865e86 Mon Sep 17 00:00:00 2001 From: yottta Date: Fri, 21 Feb 2025 14:49:22 +0200 Subject: [PATCH] Cleanup some json decoding Signed-off-by: yottta --- internal/backend/remote-state/s3/client.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/internal/backend/remote-state/s3/client.go b/internal/backend/remote-state/s3/client.go index 418b04f008..4f151f9237 100644 --- a/internal/backend/remote-state/s3/client.go +++ b/internal/backend/remote-state/s3/client.go @@ -504,16 +504,8 @@ func (c *RemoteClient) getLockInfoFromS3(ctx context.Context) (*statemgr.LockInf return nil, err } - lockContent, err := io.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("could not read the content of the lock object %q from bucket %q: %w", c.lockFilePath(), c.bucketName, err) - } - if len(lockContent) == 0 { - return nil, fmt.Errorf("empty lock info found for %q in the s3 bucket: %s", c.lockFilePath(), c.bucketName) - } - lockInfo := &statemgr.LockInfo{} - err = json.Unmarshal(lockContent, lockInfo) + err = json.NewDecoder(resp.Body).Decode(lockInfo) if err != nil { return nil, fmt.Errorf("unable to json parse the lock info %q from bucket %q: %w", c.lockFilePath(), c.bucketName, err) }