Skip to content

Commit 2b19287

Browse files
committed
more updates
1 parent 75be2c3 commit 2b19287

File tree

13 files changed

+37
-35
lines changed

13 files changed

+37
-35
lines changed

agent/agent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ func (a *agent) run() (retErr error) {
936936
connMan.startAgentAPI("send logs", gracefulShutdownBehaviorRemain,
937937
func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
938938
err := a.logSender.SendLoop(ctx, aAPI)
939-
if xerrors.Is(err, agentsdk.LogLimitExceededError) {
939+
if xerrors.Is(err, agentsdk.ErrLogLimitExceeded) {
940940
// we don't want this error to tear down the API connection and propagate to the
941941
// other routines that use the API. The LogSender has already dropped a warning
942942
// log, so just return nil here.

agent/apphealth.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ func shouldStartTicker(app codersdk.WorkspaceApp) bool {
167167
return app.Healthcheck.URL != "" && app.Healthcheck.Interval > 0 && app.Healthcheck.Threshold > 0
168168
}
169169

170-
func healthChanged(old map[uuid.UUID]codersdk.WorkspaceAppHealth, new map[uuid.UUID]codersdk.WorkspaceAppHealth) bool {
171-
for name, newValue := range new {
170+
func healthChanged(old map[uuid.UUID]codersdk.WorkspaceAppHealth, updated map[uuid.UUID]codersdk.WorkspaceAppHealth) bool {
171+
for name, newValue := range updated {
172172
oldValue, found := old[name]
173173
if !found {
174174
return true

cmd/cliui/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func main() {
371371
gitlabAuthed.Store(true)
372372
}()
373373
return cliui.ExternalAuth(inv.Context(), inv.Stdout, cliui.ExternalAuthOptions{
374-
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
374+
Fetch: func(_ context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
375375
count.Add(1)
376376
return []codersdk.TemplateVersionExternalAuth{{
377377
ID: "github",

coderd/notifications/dispatch/smtp.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ import (
3434
)
3535

3636
var (
37-
ValidationNoFromAddressErr = xerrors.New("'from' address not defined")
38-
ValidationNoToAddressErr = xerrors.New("'to' address(es) not defined")
39-
ValidationNoSmarthostErr = xerrors.New("'smarthost' address not defined")
40-
ValidationNoHelloErr = xerrors.New("'hello' not defined")
37+
ErrValidationNoFromAddress = xerrors.New("'from' address not defined")
38+
ErrValidationNoToAddress = xerrors.New("'to' address(es) not defined")
39+
ErrValidationNoSmarthost = xerrors.New("'smarthost' address not defined")
40+
ErrValidationNoHello = xerrors.New("'hello' not defined")
4141

4242
//go:embed smtp/html.gotmpl
4343
htmlTemplate string
@@ -493,7 +493,7 @@ func (*SMTPHandler) validateFromAddr(from string) (string, error) {
493493
return "", xerrors.Errorf("parse 'from' address: %w", err)
494494
}
495495
if len(addrs) != 1 {
496-
return "", ValidationNoFromAddressErr
496+
return "", ErrValidationNoFromAddress
497497
}
498498
return from, nil
499499
}
@@ -505,7 +505,7 @@ func (s *SMTPHandler) validateToAddrs(to string) ([]string, error) {
505505
}
506506
if len(addrs) == 0 {
507507
s.log.Warn(context.Background(), "no valid 'to' address(es) defined; some may be invalid", slog.F("defined", to))
508-
return nil, ValidationNoToAddressErr
508+
return nil, ErrValidationNoToAddress
509509
}
510510

511511
var out []string
@@ -522,7 +522,7 @@ func (s *SMTPHandler) validateToAddrs(to string) ([]string, error) {
522522
func (s *SMTPHandler) smarthost() (string, string, error) {
523523
smarthost := strings.TrimSpace(string(s.cfg.Smarthost))
524524
if smarthost == "" {
525-
return "", "", ValidationNoSmarthostErr
525+
return "", "", ErrValidationNoSmarthost
526526
}
527527

528528
host, port, err := net.SplitHostPort(string(s.cfg.Smarthost))
@@ -538,7 +538,7 @@ func (s *SMTPHandler) smarthost() (string, string, error) {
538538
func (s *SMTPHandler) hello() (string, error) {
539539
val := s.cfg.Hello.String()
540540
if val == "" {
541-
return "", ValidationNoHelloErr
541+
return "", ErrValidationNoHello
542542
}
543543
return val, nil
544544
}

coderd/workspaceapps/db.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (p *DBTokenProvider) Issue(ctx context.Context, rw http.ResponseWriter, r *
120120
// (later on) fails and the user is not authenticated, they will be
121121
// redirected to the login page or app auth endpoint using code below.
122122
Optional: true,
123-
SessionTokenFunc: func(r *http.Request) string {
123+
SessionTokenFunc: func(_ *http.Request) string {
124124
return issueReq.SessionToken
125125
},
126126
})
@@ -132,13 +132,14 @@ func (p *DBTokenProvider) Issue(ctx context.Context, rw http.ResponseWriter, r *
132132

133133
// Lookup workspace app details from DB.
134134
dbReq, err := appReq.getDatabase(dangerousSystemCtx, p.Database)
135-
if xerrors.Is(err, sql.ErrNoRows) {
135+
switch {
136+
case xerrors.Is(err, sql.ErrNoRows):
136137
WriteWorkspaceApp404(p.Logger, p.DashboardURL, rw, r, &appReq, nil, err.Error())
137138
return nil, "", false
138-
} else if xerrors.Is(err, errWorkspaceStopped) {
139+
case xerrors.Is(err, errWorkspaceStopped):
139140
WriteWorkspaceOffline(p.Logger, p.DashboardURL, rw, r, &appReq)
140141
return nil, "", false
141-
} else if err != nil {
142+
case err != nil:
142143
WriteWorkspaceApp500(p.Logger, p.DashboardURL, rw, r, &appReq, err, "get app details from database")
143144
return nil, "", false
144145
}

coderd/workspaceapps/proxy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const (
4545
// login page.
4646
// It is important that this URL can never match a valid app hostname.
4747
//
48-
// DEPRECATED: we no longer use this, but we still redirect from it to the
48+
// Deprecated: we no longer use this, but we still redirect from it to the
4949
// main login page.
5050
appLogoutHostname = "coder-logout"
5151
)

codersdk/agentsdk/logs.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func (l *LogSender) Flush(src uuid.UUID) {
355355
// the map.
356356
}
357357

358-
var LogLimitExceededError = xerrors.New("Log limit exceeded")
358+
var ErrLogLimitExceeded = xerrors.New("Log limit exceeded")
359359

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

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

444444
// Since elsewhere we only append to the logs, here we can remove them

codersdk/agentsdk/logs_internal_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestLogSender_LogLimitExceeded(t *testing.T) {
157157
&proto.BatchCreateLogsResponse{LogLimitExceeded: true})
158158

159159
err := testutil.RequireRecvCtx(ctx, t, loopErr)
160-
require.ErrorIs(t, err, LogLimitExceededError)
160+
require.ErrorIs(t, err, ErrLogLimitExceeded)
161161

162162
// Should also unblock WaitUntilEmpty
163163
err = testutil.RequireRecvCtx(ctx, t, empty)
@@ -180,7 +180,7 @@ func TestLogSender_LogLimitExceeded(t *testing.T) {
180180
loopErr <- err
181181
}()
182182
err = testutil.RequireRecvCtx(ctx, t, loopErr)
183-
require.ErrorIs(t, err, LogLimitExceededError)
183+
require.ErrorIs(t, err, ErrLogLimitExceeded)
184184
}
185185

186186
func TestLogSender_SkipHugeLog(t *testing.T) {

codersdk/deployment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ type DeploymentValues struct {
397397
Config serpent.YAMLConfigPath `json:"config,omitempty" typescript:",notnull"`
398398
WriteConfig serpent.Bool `json:"write_config,omitempty" typescript:",notnull"`
399399

400-
// DEPRECATED: Use HTTPAddress or TLS.Address instead.
400+
// Deprecated: Use HTTPAddress or TLS.Address instead.
401401
Address serpent.HostPort `json:"address,omitempty" typescript:",notnull"`
402402
}
403403

codersdk/richparameters.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ func validateBuildParameter(richParameter TemplateVersionParameter, buildParamet
102102
return nil
103103
}
104104

105-
var min, max int
105+
var minVal, maxVal int
106106
if richParameter.ValidationMin != nil {
107-
min = int(*richParameter.ValidationMin)
107+
minVal = int(*richParameter.ValidationMin)
108108
}
109109
if richParameter.ValidationMax != nil {
110-
max = int(*richParameter.ValidationMax)
110+
maxVal = int(*richParameter.ValidationMax)
111111
}
112112

113113
validation := &provider.Validation{
114-
Min: min,
115-
Max: max,
114+
Min: minVal,
115+
Max: maxVal,
116116
MinDisabled: richParameter.ValidationMin == nil,
117117
MaxDisabled: richParameter.ValidationMax == nil,
118118
Regex: richParameter.ValidationRegex,

codersdk/templatevariables.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,16 @@ func parseVariableValuesFromHCL(content []byte) ([]VariableValue, error) {
121121
}
122122

123123
ctyType := ctyValue.Type()
124-
if ctyType.Equals(cty.String) {
124+
switch {
125+
case ctyType.Equals(cty.String):
125126
stringData[attribute.Name] = ctyValue.AsString()
126-
} else if ctyType.Equals(cty.Number) {
127+
case ctyType.Equals(cty.Number):
127128
stringData[attribute.Name] = ctyValue.AsBigFloat().String()
128-
} else if ctyType.IsTupleType() {
129+
case ctyType.IsTupleType():
129130
// In case of tuples, Coder only supports the list(string) type.
130131
var items []string
131132
var err error
132-
_ = ctyValue.ForEachElement(func(key, val cty.Value) (stop bool) {
133+
_ = ctyValue.ForEachElement(func(_, val cty.Value) (stop bool) {
133134
if !val.Type().Equals(cty.String) {
134135
err = xerrors.Errorf("unsupported tuple item type: %s ", val.GoString())
135136
return true
@@ -146,7 +147,7 @@ func parseVariableValuesFromHCL(content []byte) ([]VariableValue, error) {
146147
return nil, err
147148
}
148149
stringData[attribute.Name] = string(m)
149-
} else {
150+
default:
150151
return nil, xerrors.Errorf("unsupported value type (name: %s): %s", attribute.Name, ctyType.GoString())
151152
}
152153
}

enterprise/audit/filter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Filter interface {
2929

3030
// DefaultFilter is the default filter used when exporting audit logs. It allows
3131
// storage and exporting for all audit logs.
32-
var DefaultFilter Filter = FilterFunc(func(ctx context.Context, alog database.AuditLog) (FilterDecision, error) {
32+
var DefaultFilter Filter = FilterFunc(func(_ context.Context, alog database.AuditLog) (FilterDecision, error) {
3333
// Store and export all audit logs for now.
3434
return FilterDecisionStore | FilterDecisionExport, nil
3535
})

scripts/apitypings/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TypeMappings(gen *guts.GoParser) error {
116116
// 'serpent.Struct' overrides the json.Marshal to use the underlying type,
117117
// so the typescript type should be the underlying type.
118118
func FixSerpentStruct(gen *guts.Typescript) {
119-
gen.ForEach(func(key string, originalNode bindings.Node) {
119+
gen.ForEach(func(_ string, originalNode bindings.Node) {
120120
isInterface, ok := originalNode.(*bindings.Interface)
121121
if ok && isInterface.Name.Ref() == "SerpentStruct" {
122122
// replace it with

0 commit comments

Comments
 (0)