Skip to content

Commit fe95cec

Browse files
committed
chore: s3 config cleanup
1 parent 922b8ba commit fe95cec

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

internal/gcphelper/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func createGCPCredentialsFromGoogleCredentialsEnv(ctx context.Context, opts *opt
137137
}
138138

139139
if err := json.Unmarshal([]byte(contents), &account); err != nil {
140-
return nil, errors.Errorf("Error parsing GCP credentials.")
140+
return nil, errors.Errorf("Error parsing GCP credentials: %w", err)
141141
}
142142

143143
conf := jwt.Config{

internal/github/client_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"path/filepath"
1010
"strings"
11+
"sync/atomic"
1112
"testing"
1213
"time"
1314

@@ -155,7 +156,7 @@ func TestGetLatestReleaseInvalidRepository(t *testing.T) {
155156
for _, repo := range testCases {
156157
t.Run(fmt.Sprintf("repo=%s", repo), func(tt *testing.T) {
157158
_, err := client.GetLatestRelease(tt.Context(), repo)
158-
require.Error(t, err)
159+
require.Error(tt, err)
159160
})
160161
}
161162
}
@@ -200,10 +201,10 @@ func TestGetLatestReleaseEmptyTag(t *testing.T) {
200201
func TestGetLatestReleaseCaching(t *testing.T) {
201202
t.Parallel()
202203

203-
callCount := 0
204+
var callCount atomic.Int32
204205
// Create a mock server that tracks how many times it's called
205206
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
206-
callCount++
207+
callCount.Add(1)
207208
w.Header().Set("Content-Type", "application/json")
208209
response := `{"tag_name": "v1.0.0"}`
209210
_, err := fmt.Fprint(w, response)
@@ -218,14 +219,14 @@ func TestGetLatestReleaseCaching(t *testing.T) {
218219
require.NoError(t, err)
219220

220221
assert.Equal(t, "v1.0.0", tag1)
221-
assert.Equal(t, 1, callCount)
222+
assert.Equal(t, int32(1), callCount.Load())
222223

223224
// Second call should use cache
224225
tag2, err := client.GetLatestReleaseTag(t.Context(), "owner/repo")
225226
require.NoError(t, err)
226227

227228
assert.Equal(t, "v1.0.0", tag2)
228-
assert.Equal(t, 1, callCount)
229+
assert.Equal(t, int32(1), callCount.Load())
229230
}
230231

231232
// Tests for GitHubReleasesDownloadClient

internal/remotestate/backend/s3/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,16 +735,16 @@ func isBucketAlreadyOwnedByYouError(err error) bool {
735735
func isBucketErrorRetriable(l log.Logger, err error) bool {
736736
var apiErr smithy.APIError
737737
if errors.As(err, &apiErr) {
738-
unrecoverable := apiErr.ErrorCode() == "InternalError" || apiErr.ErrorCode() == "OperationAborted" || apiErr.ErrorCode() == "InvalidParameter"
738+
retriable := apiErr.ErrorCode() == "InternalError" || apiErr.ErrorCode() == "OperationAborted" || apiErr.ErrorCode() == "InvalidParameter"
739739

740-
if !unrecoverable {
740+
if retriable {
741741
l.Debugf(
742742
"Encountered AWS API error '%s' during bucket creation. Assuming it's retriable and will retry.",
743743
apiErr.ErrorCode(),
744744
)
745745
}
746746

747-
return unrecoverable
747+
return retriable
748748
}
749749

750750
l.Debugf(

0 commit comments

Comments
 (0)