Skip to content

Commit 0b3571a

Browse files
committed
errname and fix changes
1 parent bb5aa17 commit 0b3571a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+125
-138
lines changed

.golangci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ issues:
231231

232232
run:
233233
timeout: 10m
234+
skip-files:
235+
- scripts/rules.go
234236

235237
# Over time, add more and more linters from
236238
# https://golangci-lint.run/usage/linters/ as the code improves.

cli/cliui/cliui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/coder/pretty"
1313
)
1414

15-
var Canceled = xerrors.New("canceled")
15+
var ErrCanceled = xerrors.New("canceled")
1616

1717
// DefaultStyles compose visual elements of the UI.
1818
var DefaultStyles Styles

cli/cliui/prompt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func Prompt(inv *serpent.Invocation, opts PromptOptions) (string, error) {
124124
return "", err
125125
case line := <-lineCh:
126126
if opts.IsConfirm && line != "yes" && line != "y" {
127-
return line, xerrors.Errorf("got %q: %w", line, Canceled)
127+
return line, xerrors.Errorf("got %q: %w", line, ErrCanceled)
128128
}
129129
if opts.Validate != nil {
130130
err := opts.Validate(line)
@@ -139,7 +139,7 @@ func Prompt(inv *serpent.Invocation, opts PromptOptions) (string, error) {
139139
case <-interrupt:
140140
// Print a newline so that any further output starts properly on a new line.
141141
_, _ = fmt.Fprintln(inv.Stdout)
142-
return "", Canceled
142+
return "", ErrCanceled
143143
}
144144
}
145145

cli/cliui/provisionerjob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func ProvisionerJob(ctx context.Context, wr io.Writer, opts ProvisionerJobOption
204204
switch job.Status {
205205
case codersdk.ProvisionerJobCanceled:
206206
jobMutex.Unlock()
207-
return Canceled
207+
return ErrCanceled
208208
case codersdk.ProvisionerJobSucceeded:
209209
jobMutex.Unlock()
210210
return nil

cli/cliui/provisionerjob_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func newProvisionerJob(t *testing.T) provisionerJobTest {
250250
defer close(done)
251251
err := inv.WithContext(context.Background()).Run()
252252
if err != nil {
253-
assert.ErrorIs(t, err, cliui.Canceled)
253+
assert.ErrorIs(t, err, cliui.ErrCanceled)
254254
}
255255
}()
256256
t.Cleanup(func() {

cli/cliui/select.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func Select(inv *serpent.Invocation, opts SelectOptions) (string, error) {
147147
}
148148

149149
if model.canceled {
150-
return "", Canceled
150+
return "", ErrCanceled
151151
}
152152

153153
return model.selected, nil
@@ -360,7 +360,7 @@ func MultiSelect(inv *serpent.Invocation, opts MultiSelectOptions) ([]string, er
360360
}
361361

362362
if model.canceled {
363-
return nil, Canceled
363+
return nil, ErrCanceled
364364
}
365365

366366
return model.selectedOptions(), nil

cli/configssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (r *RootCmd) configSSH() *serpent.Command {
268268
IsConfirm: true,
269269
})
270270
if err != nil {
271-
if line == "" && xerrors.Is(err, cliui.Canceled) {
271+
if line == "" && xerrors.Is(err, cliui.ErrCanceled) {
272272
return nil
273273
}
274274
// Selecting "no" will use the last config.

cli/externalauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fi
9191
if err != nil {
9292
return err
9393
}
94-
return cliui.Canceled
94+
return cliui.ErrCanceled
9595
}
9696
if extra != "" {
9797
if extAuth.TokenExtra == nil {

cli/externalauth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestExternalAuth(t *testing.T) {
2929
inv.Stdout = pty.Output()
3030
waiter := clitest.StartWithWaiter(t, inv)
3131
pty.ExpectMatch("https://github.com")
32-
waiter.RequireIs(cliui.Canceled)
32+
waiter.RequireIs(cliui.ErrCanceled)
3333
})
3434
t.Run("SuccessWithToken", func(t *testing.T) {
3535
t.Parallel()

cli/gitaskpass.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (r *RootCmd) gitAskpass() *serpent.Command {
5353
cliui.Warn(inv.Stderr, "Coder was unable to handle this git request. The default git behavior will be used instead.",
5454
lines...,
5555
)
56-
return cliui.Canceled
56+
return cliui.ErrCanceled
5757
}
5858
return xerrors.Errorf("get git token: %w", err)
5959
}

0 commit comments

Comments
 (0)