8000 chore: update golang to 1.24.1 by sreya · Pull Request #17035 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: update golang to 1.24.1 #17035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5df49f9
feat: update Go version to 1.24.1
Mar 21, 2025
83e79be
refactor: simplify Go 1.24.1 update
Mar 21, 2025
57a47e0
revert: simplify change to go version only
Mar 21, 2025
8187c9e
fix: update guts dependency to support Go 1.24.1
Mar 21, 2025
5aaf404
fix: update golangci-lint tool for Go 1.24.1
Mar 21, 2025
d7160ae
fix: temporarily disable Go linting due to Go 1.24.1 compatibility is…
Mar 21, 2025
3c3aa21
fix: update golangci-lint to v1.57.1 for Go 1.24.1 compatibility
Mar 21, 2025
4710808
fix: upgrade golangci-lint to v1.64.8
Mar 21, 2025
2bcb38a
revert: restore original lint/go implementation in Makefile
Mar 21, 2025
651d489
fix: restore original Makefile structure with continue-on-error for l…
Mar 21, 2025
77b2908
chore: remove continue-on-error behavior from lint/go
Mar 21, 2025
226e838
update golangci rules
sreya Mar 24, 2025
02fd64a
fix config
sreya Mar 24, 2025
3d07833
ignore unused parameters in tests
sreya Mar 25, 2025
75be2c3
update golangci rules
sreya Mar 25, 2025
2b19287
more updates
sreya Mar 25, 2025
ee44d98
fix: Add #nosec G115 annotations to address integer overflow conversi…
sreya Mar 25, 2025
f8af6a8
fix: Add more #nosec G115 annotations for integer overflow warnings
sreya Mar 25, 2025
3cf7102
fix: address G115 integer overflow linter warnings for Go 1.24.1
sreya Mar 25, 2025
527df65
fix: address more G115 integer overflow linter warnings
sreya Mar 25, 2025
7d11352
refactor: replace if-else chains with switch statements
sreya Mar 25, 2025
59e1b9c
fix: resolve unused parameter linter issues for Go 1.24.1 compatibility
sreya Mar 25, 2025
bb5aa17
fix: resolve unused-parameter warnings for Go 1.24.1 compatibility
sreya Mar 26, 2025
0b3571a
errname and fix changes
sreya Mar 26, 2025
7f93228
more fixes
sreya Mar 26, 2025
792b4b5
fix compilation error
sreya Mar 26, 2025
a4f441a
fix: resolve G115 integer overflow conversion warnings for Go 1.24.1 …
sreya Mar 26, 2025
5caf54d
fix: convert if-else chains to switch statements for Go 1.24.1 compat…
sreya Mar 26, 2025
d9b665c
fix abhorrent edits
sreya Mar 26, 2025
7e0ceec
fix more linting rules
sreya Mar 26, 2025
1530bfb
fix agent
sreya Mar 26, 2025
9ae5514
fix more stuff
sreya Mar 26, 2025
e2e1e17
fix test
sreya Mar 26, 2025
f3f5755
fix: resolve remaining redefines-builtin-id linting issues
sreya Mar 26, 2025
9b0a218
fix appendAssign
sreya Mar 26, 2025
d3581a8
fix: resolve deferUnlambda linting issues by simplifying defer statem…
sreya Mar 26, 2025
1bb7942
fix ifelse
sreya Mar 26, 2025
31311d3
fix assignOp linting errors
Mar 26, 2025
3b93057
Revert "fix: resolve deferUnlambda linting issues by simplifying defe…
sreya Mar 26, 2025
3a4ac1e
unlambda && make gen
sreya Mar 26, 2025
38de0cf
don't commit dbmock
sreya Mar 26, 2025
3afeb90
make gen
sreya Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more updates
  • Loading branch information
sreya committed Mar 25, 2025
commit 2b19287d2f5e9a540a847d85d1497f8d21d479cc
2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ func (a *agent) run() (retErr error) {
connMan.startAgentAPI("send logs", gracefulShutdownBehaviorRemain,
func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
err := a.logSender.SendLoop(ctx, aAPI)
if xerrors.Is(err, agentsdk.LogLimitExceededError) {
if xerrors.Is(err, agentsdk.ErrLogLimitExceeded) {
// we don't want this error to tear down the API connection and propagate to the
// other routines that use the API. The LogSender has already dropped a warning
// log, so just return nil here.
Expand Down
4 changes: 2 additions & 2 deletions agent/apphealth.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func shouldStartTicker(app codersdk.WorkspaceApp) bool {
return app.Healthcheck.URL != "" && app.Healthcheck.Interval > 0 && app.Healthcheck.Threshold > 0
}

func healthChanged(old map[uuid.UUID]codersdk.WorkspaceAppHealth, new map[uuid.UUID]codersdk.WorkspaceAppHealth) bool {
for name, newValue := range new {
func healthChanged(old map[uuid.UUID]codersdk.WorkspaceAppHealth, updated map[uuid.UUID]codersdk.WorkspaceAppHealth) bool {
for name, newValue := range updated {
oldValue, found := old[name]
if !found {
return true
Expand Down
2 changes: 1 addition & 1 deletion cmd/cliui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func main() {
gitlabAuthed.Store(true)
}()
return cliui.ExternalAuth(inv.Context(), inv.Stdout, cliui.ExternalAuthOptions{
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
Fetch: func(_ context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
count.Add(1)
return []codersdk.TemplateVersionExternalAuth{{
ID: "github",
Expand Down
16 changes: 8 additions & 8 deletions coderd/notifications/dispatch/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import (
)

var (
ValidationNoFromAddressErr = xerrors.New("'from' address not defined")
ValidationNoToAddressErr = xerrors.New("'to' address(es) not defined")
ValidationNoSmarthostErr = xerrors.New("'smarthost' address not defined")
ValidationNoHelloErr = xerrors.New("'hello' not defined")
ErrValidationNoFromAddress = xerrors.New("'from' address not defined")
ErrValidationNoToAddress = xerrors.New("'to' address(es) not defined")
ErrValidationNoSmarthost = xerrors.New("'smarthost' address not defined")
ErrValidationNoHello = xerrors.New("'hello' not defined")

//go:embed smtp/html.gotmpl
htmlTemplate string
Expand Down Expand Up @@ -493,7 +493,7 @@ func (*SMTPHandler) validateFromAddr(from string) (string, error) {
return "", xerrors.Errorf("parse 'from' address: %w", err)
}
if len(addrs) != 1 {
return "", ValidationNoFromAddressErr
return "", ErrValidationNoFromAddress
}
return from, nil
}
Expand All @@ -505,7 +505,7 @@ func (s *SMTPHandler) validateToAddrs(to string) ([]string, error) {
}
if len(addrs) == 0 {
s.log.Warn(context.Background(), "no valid 'to' address(es) defined; some may be invalid", slog.F("defined", to))
return nil, ValidationNoToAddressErr
return nil, ErrValidationNoToAddress
}

var out []string
Expand All @@ -522,7 +522,7 @@ func (s *SMTPHandler) validateToAddrs(to string) ([]string, error) {
func (s *SMTPHandler) smarthost() (string, string, error) {
smarthost := strings.TrimSpace(string(s.cfg.Smarthost))
if smarthost == "" {
return "", "", ValidationNoSmarthostErr
return "", "", ErrValidationNoSmarthost
}

host, port, err := net.SplitHostPort(string(s.cfg.Smarthost))
Expand All @@ -538,7 +538,7 @@ func (s *SMTPHandler) smarthost() (string, string, error) {
func (s *SMTPHandler) hello() (string, error) {
val := s.cfg.Hello.String()
if val == "" {
return "", ValidationNoHelloErr
return "", ErrValidationNoHello
}
return val, nil
}
Expand Down
9 changes: 5 additions & 4 deletions coderd/workspaceapps/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (p *DBTokenProvider) Issue(ctx context.Context, rw http.ResponseWriter, r *
// (later on) fails and the user is not authenticated, they will be
// redirected to the login page or app auth endpoint using code below.
Optional: true,
SessionTokenFunc: func(r *http.Request) string {
SessionTokenFunc: func(_ *http.Request) string {
return issueReq.SessionToken
},
})
Expand All @@ -132,13 +132,14 @@ func (p *DBTokenProvider) Issue(ctx context.Context, rw http.ResponseWriter, r *

// Lookup workspace app details from DB.
dbReq, err := appReq.getDatabase(dangerousSystemCtx, p.Database)
if xerrors.Is(err, sql.ErrNoRows) {
switch {
case xerrors.Is(err, sql.ErrNoRows):
WriteWorkspaceApp404(p.Logger, p.DashboardURL, rw, r, &appReq, nil, err.Error())
return nil, "", false
} else if xerrors.Is(err, errWorkspaceStopped) {
case xerrors.Is(err, errWorkspaceStopped):
WriteWorkspaceOffline(p.Logger, p.DashboardURL, rw, r, &appReq)
return nil, "", false
} else if err != nil {
case err != nil:
WriteWorkspaceApp500(p.Logger, p.DashboardURL, rw, r, &appReq, err, "get app details from database")
return nil, "", false
}
Expand Down
2 changes: 1 addition & 1 deletion coderd/workspaceapps/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (
// login page.
// It is important that this URL can never match a valid app hostname.
//
// DEPRECATED: we no longer use this, but we still redirect from it to the
// Deprecated: we no longer use this, but we still redirect from it to the
// main login page.
appLogoutHostname = "coder-logout"
)
Expand Down
6 changes: 3 additions & 3 deletions codersdk/agentsdk/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (l *LogSender) Flush(src uuid.UUID) {
// the map.
}

var LogLimitExceededError = xerrors.New("Log limit exceeded")
var ErrLogLimitExceeded = xerrors.New("Log limit exceeded")

// SendLoop sends any pending logs until it hits an error or the context is canceled. It does not
// retry as it is expected that a higher layer retries establishing connection to the agent API and
Expand All @@ -365,7 +365,7 @@ func (l *LogSender) SendLoop(ctx context.Context, dest LogDest) error {
defer l.L.Unlock()
if l.exceededLogLimit {
l.logger.Debug(ctx, "aborting SendLoop because log limit is already exceeded")
return LogLimitExceededError
return ErrLogLimitExceeded
}

ctxDone := false
Expand Down Expand Up @@ -438,7 +438,7 @@ func (l *LogSender) SendLoop(ctx context.Context, dest LogDest) error {
// no point in keeping anything we have queued around, server will not accept them
l.queues = make(map[uuid.UUID]*logQueue)
l.Broadcast() // might unblock WaitUntilEmpty
return LogLimitExceededError
return ErrLogLimitExceeded
}

// Since elsewhere we only append to the logs, here we can remove them
Expand Down
4 changes: 2 additions & 2 deletions codersdk/agentsdk/logs_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestLogSender_LogLimitExceeded(t *testing.T) {
&proto.BatchCreateLogsResponse{LogLimitExceeded: true})

err := testutil.RequireRecvCtx(ctx, t, loopErr)
require.ErrorIs(t, err, LogLimitExceededError)
require.ErrorIs(t, err, ErrLogLimitExceeded)

// Should also unblock WaitUntilEmpty
err = testutil.RequireRecvCtx(ctx, t, empty)
Expand All @@ -180,7 +180,7 @@ func TestLogSender_LogLimitExceeded(t *testing.T) {
loopErr <- err
}()
err = testutil.RequireRecvCtx(ctx, t, loopErr)
require.ErrorIs(t, err, LogLimitExceededError)
require.ErrorIs(t, err, ErrLogLimitExceeded)
}

func TestLogSender_SkipHugeLog(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ type DeploymentValues struct {
Config serpent.YAMLConfigPath `json:"config,omitempty" typescript:",notnull"`
WriteConfig serpent.Bool `json:"write_config,omitempty" typescript:",notnull"`

// DEPRECATED: Use HTTPAddress or TLS.Address instead.
// Deprecated: Use HTTPAddress or TLS.Address instead.
Address serpent.HostPort `json:"address,omitempty" typescript:",notnull"`
}

Expand Down
10 changes: 5 additions & 5 deletions codersdk/richparameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ func validateBuildParameter(richParameter TemplateVersionParameter, buildParamet
return nil
}

var min, max int
var minVal, maxVal int
if richParameter.ValidationMin != nil {
min = int(*richParameter.ValidationMin)
minVal = int(*richParameter.ValidationMin)
}
if richParameter.ValidationMax != nil {
max = int(*richParameter.ValidationMax)
maxVal = int(*richParameter.ValidationMax)
}

validation := &provider.Validation{
Min: min,
Max: max,
Min: minVal,
Max: maxVal,
MinDisabled: richParameter.ValidationMin == nil,
MaxDisabled: richParameter.ValidationMax == nil,
Regex: richParameter.ValidationRegex,
Expand Down
11 changes: 6 additions & 5 deletions codersdk/templatevariables.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ func parseVariableValuesFromHCL(content []byte) ([]VariableValue, error) {
}

ctyType := ctyValue.Type()
if ctyType.Equals(cty.String) {
switch {
case ctyType.Equals(cty.String):
stringData[attribute.Name] = ctyValue.AsString()
} else if ctyType.Equals(cty.Number) {
case ctyType.Equals(cty.Number):
stringData[attribute.Name] = ctyValue.AsBigFloat().String()
} else if ctyType.IsTupleType() {
case ctyType.IsTupleType():
// In case of tuples, Coder only supports the list(string) type.
var items []string
var err error
_ = ctyValue.ForEachElement(func(key, val cty.Value) (stop bool) {
_ = ctyValue.ForEachElement(func(_, val cty.Value) (stop bool) {
if !val.Type().Equals(cty.String) {
err = xerrors.Errorf("unsupported tuple item type: %s ", val.GoString())
return true
Expand All @@ -146,7 +147,7 @@ func parseVariableValuesFromHCL(content []byte) ([]VariableValue, error) {
return nil, err
}
stringData[attribute.Name] = string(m)
} else {
default:
return nil, xerrors.Errorf("unsupported value type (name: %s): %s", attribute.Name, ctyType.GoString())
}
}
Expand Down
2 changes: 1 addition & 1 deletion enterprise/audit/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Filter interface {

// DefaultFilter is the default filter used when exporting audit logs. It allows
// storage and exporting for all audit logs.
var DefaultFilter Filter = FilterFunc(func(ctx context.Context, alog database.AuditLog) (FilterDecision, error) {
var DefaultFilter Filter = FilterFunc(func(_ context.Context, alog database.AuditLog) (FilterDecision, error) {
// Store and export all audit logs for now.
return FilterDecisionStore | FilterDecisionExport, nil
})
Expand Down
2 changes: 1 addition & 1 deletion scripts/apitypings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TypeMappings(gen *guts.GoParser) error {
// 'serpent.Struct' overrides the json.Marshal to use the underlying type,
// so the typescript type should be the underlying type.
func FixSerpentStruct(gen *guts.Typescript) {
gen.ForEach(func(key string, originalNode bindings.Node) {
gen.ForEach(func(_ string, originalNode bindings.Node) {
isInterface, ok := originalNode.(*bindings.Interface)
if ok && isInterface.Name.Ref() == "SerpentStruct" {
// replace it with
Expand Down
Loading
0