Skip to content

Commit 08863bf

Browse files
authored
chore: upgrade to go 1.24 (#391)
1 parent b5ff02b commit 08863bf

22 files changed

+173
-46
lines changed

.golangci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ linters:
101101
- errname
102102
- errorlint
103103
- exhaustive
104-
- exportloopref
105104
# TODO(forbidigo): revisit
106105
#- forbidigo
107106
- forcetypeassert
@@ -145,7 +144,7 @@ linters:
145144
# TODO(stylecheck): revisit in a followup; some breaking API changes
146145
#- stylecheck
147146
# NOTE: removed tagliatelle as it conflicts too much with existing API wireformats
148-
- tenv
147+
# - TODO(usetesting)
149148
# TODO(testpackage): improve open vs closed-box testing in a followup
150149
#- testpackage
151150
- thelper

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GOOS = $(shell go env GOOS)
33
GOARCH = $(shell go env GOARCH)
44

55
GO_BIN := $(shell pwd)/.bin
6-
OVERRIDE_GOCI_LINT_V := v1.60.1
6+
OVERRIDE_GOCI_LINT_V := v1.64.8
77
SHELL := env PATH=$(GO_BIN):$(shell go env GOROOT)/bin:$(PATH) $(SHELL)
88

99
.PHONY: format

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/snyk/go-application-framework
22

3-
go 1.23.6
3+
go 1.24
44

55
require (
66
github.com/charmbracelet/lipgloss v0.10.0

internal/utils/temp-dir_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func Test_systemTempDirectory_handlesWhenTempDirNotExists(t *testing.T) {
6565
tempDir, err := systemTempDirectory(logger, osutil)
6666
assert.Nil(t, err)
6767
assert.Equal(t, expectedDir, tempDir)
68-
assert.Equal(t, expectedDir, osutil.(*mockTempDirOSUtil).dirPath)
69-
assert.Equal(t, FILEPERM_755, osutil.(*mockTempDirOSUtil).dirPerm)
68+
assert.Equal(t, expectedDir, osutil.(*mockTempDirOSUtil).dirPath) //nolint:errcheck //in this test, the type is fix
69+
assert.Equal(t, FILEPERM_755, osutil.(*mockTempDirOSUtil).dirPerm) //nolint:errcheck //in this test, the type is fix
7070
}
7171

7272
func Test_systemTempDirectory_handlesTempDirFailure(t *testing.T) {
@@ -106,8 +106,8 @@ func Test_snykTempDirectoryImpl_handlesWhenSnykTempDirNotExists(t *testing.T) {
106106
tempDir, err := snykTempDirectoryImpl(logger, osutil)
107107
assert.Nil(t, err)
108108
assert.Equal(t, expectedResult, tempDir)
109-
assert.Equal(t, expectedResult, osutil.(*mockTempDirOSUtil).dirPath)
110-
assert.Equal(t, FILEPERM_755, osutil.(*mockTempDirOSUtil).dirPerm)
109+
assert.Equal(t, expectedResult, osutil.(*mockTempDirOSUtil).dirPath) //nolint:errcheck //in this test, the type is fix
110+
assert.Equal(t, FILEPERM_755, osutil.(*mockTempDirOSUtil).dirPerm) //nolint:errcheck //in this test, the type is fix
111111
}
112112

113113
func Test_snykTempDirectoryImpl_handlesSnykTempDirFailure(t *testing.T) {

pkg/analytics/analytics_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package analytics
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/snyk/go-application-framework/pkg/logging"
76
"io"
87
"net/http"
98
"os/user"
109
"strings"
1110
"testing"
1211

12+
"github.com/snyk/go-application-framework/pkg/logging"
13+
1314
"github.com/stretchr/testify/assert"
1415
)
1516

@@ -237,7 +238,7 @@ func Test_SanitizeUsername(t *testing.T) {
237238
func newTestAnalytics(t *testing.T) Analytics {
238239
t.Helper()
239240
a := New()
240-
a.(*AnalyticsImpl).userCurrent = testUserCurrent(t)
241+
a.(*AnalyticsImpl).userCurrent = testUserCurrent(t) //nolint:errcheck //in this test, the type is clear
241242
return a
242243
}
243244

pkg/app/app.go

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

33
import (
4+
"crypto/fips140"
45
"io"
56
"log"
67
"net/http"
@@ -251,6 +252,7 @@ func initConfiguration(engine workflow.Engine, config configuration.Configuratio
251252
config.AddDefaultValue(configuration.PREVIEW_FEATURES_ENABLED, defaultPreviewFeaturesEnabled(engine))
252253
config.AddDefaultValue(configuration.CUSTOM_CONFIG_FILES, customConfigFiles(config))
253254
config.AddDefaultValue(middleware.ConfigurationKeyRetryAttempts, defaultMaxNetworkRetryAttempts(engine))
255+
config.AddDefaultValue(configuration.FIPS_ENABLED, configuration.StandardDefaultValueFunction(fips140.Enabled()))
254256
}
255257

256258
func customConfigFiles(config configuration.Configuration) configuration.DefaultValueFunction {

pkg/auth/oauth2authenticator_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ func Test_AddAuthenticationHeader_validToken(t *testing.T) {
173173

174174
config := configuration.NewWithOpts()
175175
authenticator := NewOAuth2AuthenticatorWithOpts(config)
176-
err := authenticator.(*oAuth2Authenticator).persistToken(newToken)
176+
err := authenticator.(*oAuth2Authenticator).persistToken(newToken) //nolint:errcheck //in this test, the type is clear
177177
assert.NoError(t, err)
178-
authenticator.(*oAuth2Authenticator).tokenRefresherFunc = func(_ context.Context, _ *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error) {
178+
authenticator.(*oAuth2Authenticator).tokenRefresherFunc = func(_ context.Context, _ *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error) { //nolint:errcheck //in this test, the type is clear
179179
assert.False(t, true, "The token is valid and no refresh is required!")
180180
return newToken, nil
181181
}
@@ -197,7 +197,7 @@ func Test_AddAuthenticationHeader_validToken(t *testing.T) {
197197
actualToken, err := GetOAuthToken(config)
198198
assert.NoError(t, err)
199199
assert.Equal(t, *newToken, *actualToken)
200-
assert.Equal(t, *newToken, *authenticator.(*oAuth2Authenticator).token)
200+
assert.Equal(t, *newToken, *authenticator.(*oAuth2Authenticator).token) //nolint:errcheck //in this test, the type is clear
201201
}
202202

203203
func Test_AddAuthenticationHeader_expiredToken(t *testing.T) {
@@ -218,9 +218,9 @@ func Test_AddAuthenticationHeader_expiredToken(t *testing.T) {
218218

219219
config := configuration.NewWithOpts()
220220
authenticator := NewOAuth2AuthenticatorWithOpts(config)
221-
err := authenticator.(*oAuth2Authenticator).persistToken(expiredToken)
221+
err := authenticator.(*oAuth2Authenticator).persistToken(expiredToken) //nolint:errcheck //in this test, the type is clear
222222
assert.NoError(t, err)
223-
authenticator.(*oAuth2Authenticator).tokenRefresherFunc = func(_ context.Context, _ *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error) {
223+
authenticator.(*oAuth2Authenticator).tokenRefresherFunc = func(_ context.Context, _ *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error) { //nolint:errcheck //in this test, the type is clear
224224
return newToken, nil
225225
}
226226

@@ -241,7 +241,7 @@ func Test_AddAuthenticationHeader_expiredToken(t *testing.T) {
241241
actualToken, err := GetOAuthToken(config)
242242
assert.NoError(t, err)
243243
assert.Equal(t, *newToken, *actualToken)
244-
assert.Equal(t, *newToken, *authenticator.(*oAuth2Authenticator).token)
244+
assert.Equal(t, *newToken, *authenticator.(*oAuth2Authenticator).token) //nolint:errcheck //in this test, the type is clear
245245
}
246246

247247
func Test_AddAuthenticationHeader_expiredToken_somebodyUpdated(t *testing.T) {
@@ -262,9 +262,9 @@ func Test_AddAuthenticationHeader_expiredToken_somebodyUpdated(t *testing.T) {
262262

263263
config := configuration.NewWithOpts()
264264
authenticator := NewOAuth2AuthenticatorWithOpts(config)
265-
err := authenticator.(*oAuth2Authenticator).persistToken(expiredToken)
265+
err := authenticator.(*oAuth2Authenticator).persistToken(expiredToken) //nolint:errcheck //in this test, the type is clear
266266
assert.NoError(t, err)
267-
authenticator.(*oAuth2Authenticator).tokenRefresherFunc = func(_ context.Context, _ *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error) {
267+
authenticator.(*oAuth2Authenticator).tokenRefresherFunc = func(_ context.Context, _ *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error) { //nolint:errcheck //in this test, the type is clear
268268
assert.False(t, true, "The token is valid and no refresh is required!")
269269
return newToken, nil
270270
}
@@ -275,7 +275,7 @@ func Test_AddAuthenticationHeader_expiredToken_somebodyUpdated(t *testing.T) {
275275

276276
// have authenticator2 update the token "in parallel"
277277
authenticator2 := NewOAuth2AuthenticatorWithOpts(config)
278-
err = authenticator2.(*oAuth2Authenticator).persistToken(newToken)
278+
err = authenticator2.(*oAuth2Authenticator).persistToken(newToken) //nolint:errcheck //in this test, the type is clear
279279
assert.NoError(t, err)
280280

281281
// run method under test
@@ -291,7 +291,7 @@ func Test_AddAuthenticationHeader_expiredToken_somebodyUpdated(t *testing.T) {
291291
actualToken, err := GetOAuthToken(config)
292292
assert.NoError(t, err)
293293
assert.Equal(t, *newToken, *actualToken)
294-
assert.Equal(t, *newToken, *authenticator.(*oAuth2Authenticator).token)
294+
assert.Equal(t, *newToken, *authenticator.(*oAuth2Authenticator).token) //nolint:errcheck //in this test, the type is clear
295295
}
296296

297297
func Test_determineGrantType_empty(t *testing.T) {

pkg/auth/oauth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func getAccessTokenWithSingleAudienceClaim(t *testing.T, audience string) string
1717
claims := &jws.ClaimSet{
1818
Aud: audience,
1919
}
20-
pk, err := rsa.GenerateKey(rand.Reader, 1023)
20+
pk, err := rsa.GenerateKey(rand.Reader, 2048)
2121
assert.NoError(t, err)
2222

2323
accessToken, err := jws.Encode(header, claims, pk)

pkg/configuration/configuration_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ func Test_ConfigurationClone(t *testing.T) {
351351
assert.Equal(t, expectedAlternateValue, actualAlternateValue)
352352

353353
// we assume that a cloned configuration uses the same storage object. Just the pointer is cloned.
354-
assert.Equal(t, config.(*extendedViper).storage, clonedConfig.(*extendedViper).storage)
355-
assert.Equal(t, config.(*extendedViper).automaticEnvEnabled, clonedConfig.(*extendedViper).automaticEnvEnabled)
354+
assert.Equal(t, config.(*extendedViper).storage, clonedConfig.(*extendedViper).storage) //nolint:errcheck //in this test, the type is clear
355+
assert.Equal(t, config.(*extendedViper).automaticEnvEnabled, clonedConfig.(*extendedViper).automaticEnvEnabled) //nolint:errcheck //in this test, the type is clear
356356

357357
cleanupConfigstore(t)
358358
}
@@ -377,7 +377,7 @@ func TestNewFromFiles(t *testing.T) {
377377
func TestNewInMemory_shouldNotBreakWhenTryingToPersist(t *testing.T) {
378378
config := NewInMemory()
379379

380-
assert.Nil(t, config.(*extendedViper).storage)
380+
assert.Nil(t, config.(*extendedViper).storage) //nolint:errcheck //in this test, the type is clear
381381
assert.NotNil(t, config)
382382

383383
const key = "test"

pkg/local_workflows/code_workflow_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func Test_Code_entrypoint(t *testing.T) {
9898
rs, err := engine.InvokeWithConfig(WORKFLOWID_CODE, config)
9999
assert.NoError(t, err)
100100
assert.NotNil(t, rs)
101-
assert.Equal(t, expectedData, rs[0].GetPayload().(string))
101+
assert.Equal(t, expectedData, rs[0].GetPayload().(string)) //nolint:errcheck //in this test, the type is clear
102102
assert.Equal(t, 2, sastSettingsCalled)
103103
}
104104

@@ -141,7 +141,7 @@ func Test_Code_legacyImplementation_happyPath(t *testing.T) {
141141
rs, err := engine.InvokeWithConfig(WORKFLOWID_CODE, config)
142142
assert.NoError(t, err)
143143
assert.NotNil(t, rs)
144-
assert.Equal(t, expectedData, rs[0].GetPayload().(string))
144+
assert.Equal(t, expectedData, rs[0].GetPayload().(string)) //nolint:errcheck //in this test, the type is clear
145145
}
146146

147147
func Test_Code_nativeImplementation_happyPath(t *testing.T) {
@@ -226,7 +226,7 @@ func Test_Code_nativeImplementation_happyPath(t *testing.T) {
226226
for _, v := range rs {
227227
if v.GetContentType() == content_type.TEST_SUMMARY {
228228
actualSummary := &json_schemas.TestSummary{}
229-
err = json.Unmarshal(v.GetPayload().([]byte), actualSummary)
229+
err = json.Unmarshal(v.GetPayload().([]byte), actualSummary) //nolint:errcheck //in this test, the type is clear
230230
assert.NoError(t, err)
231231

232232
count := 0

0 commit comments

Comments
 (0)