mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: update golang to 1.24.1 (#17035)
- Update go.mod to use Go 1.24.1 - Update GitHub Actions setup-go action to use Go 1.24.1 - Fix linting issues with golangci-lint by: - Updating to golangci-lint v1.57.1 (more compatible with Go 1.24.1) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <claude@anthropic.com>
This commit is contained in:
+6
-4
@@ -127,6 +127,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
||||
logger.Info(ctx, "spawning reaper process")
|
||||
// Do not start a reaper on the child process. It's important
|
||||
// to do this else we fork bomb ourselves.
|
||||
//nolint:gocritic
|
||||
args := append(os.Args, "--no-reap")
|
||||
err := reaper.ForkReap(
|
||||
reaper.WithExecArgs(args...),
|
||||
@@ -327,10 +328,11 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
||||
}
|
||||
|
||||
agnt := agent.New(agent.Options{
|
||||
Client: client,
|
||||
Logger: logger,
|
||||
LogDir: logDir,
|
||||
ScriptDataDir: scriptDataDir,
|
||||
Client: client,
|
||||
Logger: logger,
|
||||
LogDir: logDir,
|
||||
ScriptDataDir: scriptDataDir,
|
||||
// #nosec G115 - Safe conversion as tailnet listen port is within uint16 range (0-65535)
|
||||
TailnetListenPort: uint16(tailnetListenPort),
|
||||
ExchangeToken: func(ctx context.Context) (string, error) {
|
||||
if exchangeToken == nil {
|
||||
|
||||
@@ -19,6 +19,7 @@ func (*Statter) Disk(p Prefix, path string) (*Result, error) {
|
||||
return nil, err
|
||||
}
|
||||
var r Result
|
||||
// #nosec G115 - Safe conversion because stat.Bsize is always positive and within uint64 range
|
||||
r.Total = ptr.To(float64(stat.Blocks * uint64(stat.Bsize)))
|
||||
r.Used = float64(stat.Blocks-stat.Bfree) * float64(stat.Bsize)
|
||||
r.Unit = "B"
|
||||
|
||||
@@ -58,6 +58,7 @@ func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *serpent.Command,
|
||||
ExtractCommandPathsLoop:
|
||||
for _, cp := range extractVisibleCommandPaths(nil, root.Children) {
|
||||
name := fmt.Sprintf("coder %s --help", strings.Join(cp, " "))
|
||||
//nolint:gocritic
|
||||
cmd := append(cp, "--help")
|
||||
for _, tt := range cases {
|
||||
if tt.Name == name {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/coder/pretty"
|
||||
)
|
||||
|
||||
var Canceled = xerrors.New("canceled")
|
||||
var ErrCanceled = xerrors.New("canceled")
|
||||
|
||||
// DefaultStyles compose visual elements of the UI.
|
||||
var DefaultStyles Styles
|
||||
|
||||
@@ -33,7 +33,8 @@ func RichParameter(inv *serpent.Invocation, templateVersionParameter codersdk.Te
|
||||
|
||||
var err error
|
||||
var value string
|
||||
if templateVersionParameter.Type == "list(string)" {
|
||||
switch {
|
||||
case templateVersionParameter.Type == "list(string)":
|
||||
// Move the cursor up a single line for nicer display!
|
||||
_, _ = fmt.Fprint(inv.Stdout, "\033[1A")
|
||||
|
||||
@@ -60,7 +61,7 @@ func RichParameter(inv *serpent.Invocation, templateVersionParameter codersdk.Te
|
||||
)
|
||||
value = string(v)
|
||||
}
|
||||
} else if len(templateVersionParameter.Options) > 0 {
|
||||
case len(templateVersionParameter.Options) > 0:
|
||||
// Move the cursor up a single line for nicer display!
|
||||
_, _ = fmt.Fprint(inv.Stdout, "\033[1A")
|
||||
var richParameterOption *codersdk.TemplateVersionParameterOption
|
||||
@@ -74,7 +75,7 @@ func RichParameter(inv *serpent.Invocation, templateVersionParameter codersdk.Te
|
||||
pretty.Fprintf(inv.Stdout, DefaultStyles.Prompt, "%s\n", richParameterOption.Name)
|
||||
value = richParameterOption.Value
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
text := "Enter a value"
|
||||
if !templateVersionParameter.Required {
|
||||
text += fmt.Sprintf(" (default: %q)", defaultValue)
|
||||
|
||||
+2
-2
@@ -124,7 +124,7 @@ func Prompt(inv *serpent.Invocation, opts PromptOptions) (string, error) {
|
||||
return "", err
|
||||
case line := <-lineCh:
|
||||
if opts.IsConfirm && line != "yes" && line != "y" {
|
||||
return line, xerrors.Errorf("got %q: %w", line, Canceled)
|
||||
return line, xerrors.Errorf("got %q: %w", line, ErrCanceled)
|
||||
}
|
||||
if opts.Validate != nil {
|
||||
err := opts.Validate(line)
|
||||
@@ -139,7 +139,7 @@ func Prompt(inv *serpent.Invocation, opts PromptOptions) (string, error) {
|
||||
case <-interrupt:
|
||||
// Print a newline so that any further output starts properly on a new line.
|
||||
_, _ = fmt.Fprintln(inv.Stdout)
|
||||
return "", Canceled
|
||||
return "", ErrCanceled
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ func ProvisionerJob(ctx context.Context, wr io.Writer, opts ProvisionerJobOption
|
||||
switch job.Status {
|
||||
case codersdk.ProvisionerJobCanceled:
|
||||
jobMutex.Unlock()
|
||||
return Canceled
|
||||
return ErrCanceled
|
||||
case codersdk.ProvisionerJobSucceeded:
|
||||
jobMutex.Unlock()
|
||||
return nil
|
||||
|
||||
@@ -250,7 +250,7 @@ func newProvisionerJob(t *testing.T) provisionerJobTest {
|
||||
defer close(done)
|
||||
err := inv.WithContext(context.Background()).Run()
|
||||
if err != nil {
|
||||
assert.ErrorIs(t, err, cliui.Canceled)
|
||||
assert.ErrorIs(t, err, cliui.ErrCanceled)
|
||||
}
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ func Select(inv *serpent.Invocation, opts SelectOptions) (string, error) {
|
||||
}
|
||||
|
||||
if model.canceled {
|
||||
return "", Canceled
|
||||
return "", ErrCanceled
|
||||
}
|
||||
|
||||
return model.selected, nil
|
||||
@@ -360,7 +360,7 @@ func MultiSelect(inv *serpent.Invocation, opts MultiSelectOptions) ([]string, er
|
||||
}
|
||||
|
||||
if model.canceled {
|
||||
return nil, Canceled
|
||||
return nil, ErrCanceled
|
||||
}
|
||||
|
||||
return model.selectedOptions(), nil
|
||||
|
||||
@@ -32,7 +32,9 @@ func Distance(a, b string, maxDist int) (int, error) {
|
||||
if len(b) > 255 {
|
||||
return 0, xerrors.Errorf("levenshtein: b must be less than 255 characters long")
|
||||
}
|
||||
// #nosec G115 - Safe conversion since we've checked that len(a) < 255
|
||||
m := uint8(len(a))
|
||||
// #nosec G115 - Safe conversion since we've checked that len(b) < 255
|
||||
n := uint8(len(b))
|
||||
|
||||
// Special cases for empty strings
|
||||
@@ -70,12 +72,13 @@ func Distance(a, b string, maxDist int) (int, error) {
|
||||
subCost = 1
|
||||
}
|
||||
// Don't forget: matrix is +1 size
|
||||
d[i+1][j+1] = min(
|
||||
d[i+1][j+1] = minOf(
|
||||
d[i][j+1]+1, // deletion
|
||||
d[i+1][j]+1, // insertion
|
||||
d[i][j]+subCost, // substitution
|
||||
)
|
||||
// check maxDist on the diagonal
|
||||
// #nosec G115 - Safe conversion as maxDist is expected to be small for edit distances
|
||||
if maxDist > -1 && i == j && d[i+1][j+1] > uint8(maxDist) {
|
||||
return int(d[i+1][j+1]), ErrMaxDist
|
||||
}
|
||||
@@ -85,9 +88,9 @@ func Distance(a, b string, maxDist int) (int, error) {
|
||||
return int(d[m][n]), nil
|
||||
}
|
||||
|
||||
func min[T constraints.Ordered](ts ...T) T {
|
||||
func minOf[T constraints.Ordered](ts ...T) T {
|
||||
if len(ts) == 0 {
|
||||
panic("min: no arguments")
|
||||
panic("minOf: no arguments")
|
||||
}
|
||||
m := ts[0]
|
||||
for _, t := range ts[1:] {
|
||||
|
||||
+1
-1
@@ -268,7 +268,7 @@ func (r *RootCmd) configSSH() *serpent.Command {
|
||||
IsConfirm: true,
|
||||
})
|
||||
if err != nil {
|
||||
if line == "" && xerrors.Is(err, cliui.Canceled) {
|
||||
if line == "" && xerrors.Is(err, cliui.ErrCanceled) {
|
||||
return nil
|
||||
}
|
||||
// Selecting "no" will use the last config.
|
||||
|
||||
+4
-3
@@ -104,7 +104,8 @@ func (r *RootCmd) create() *serpent.Command {
|
||||
|
||||
var template codersdk.Template
|
||||
var templateVersionID uuid.UUID
|
||||
if templateName == "" {
|
||||
switch {
|
||||
case templateName == "":
|
||||
_, _ = fmt.Fprintln(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Wrap, "Select a template below to preview the provisioned infrastructure:"))
|
||||
|
||||
templates, err := client.Templates(inv.Context(), codersdk.TemplateFilter{})
|
||||
@@ -161,13 +162,13 @@ func (r *RootCmd) create() *serpent.Command {
|
||||
|
||||
template = templateByName[option]
|
||||
templateVersionID = template.ActiveVersionID
|
||||
} else if sourceWorkspace.LatestBuild.TemplateVersionID != uuid.Nil {
|
||||
case sourceWorkspace.LatestBuild.TemplateVersionID != uuid.Nil:
|
||||
template, err = client.Template(inv.Context(), sourceWorkspace.TemplateID)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("get template by name: %w", err)
|
||||
}
|
||||
templateVersionID = sourceWorkspace.LatestBuild.TemplateVersionID
|
||||
} else {
|
||||
default:
|
||||
templates, err := client.Templates(inv.Context(), codersdk.TemplateFilter{
|
||||
ExactName: templateName,
|
||||
})
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ func (RootCmd) errorExample() *serpent.Command {
|
||||
errorCmd := func(use string, err error) *serpent.Command {
|
||||
return &serpent.Command{
|
||||
Use: use,
|
||||
Handler: func(inv *serpent.Invocation) error {
|
||||
Handler: func(_ *serpent.Invocation) error {
|
||||
return err
|
||||
},
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (RootCmd) errorExample() *serpent.Command {
|
||||
// A multi-error
|
||||
{
|
||||
Use: "multi-error",
|
||||
Handler: func(inv *serpent.Invocation) error {
|
||||
Handler: func(_ *serpent.Invocation) error {
|
||||
return xerrors.Errorf("wrapped: %w", errors.Join(
|
||||
xerrors.Errorf("first error: %w", errorWithStackTrace()),
|
||||
xerrors.Errorf("second error: %w", errorWithStackTrace()),
|
||||
@@ -81,7 +81,7 @@ func (RootCmd) errorExample() *serpent.Command {
|
||||
{
|
||||
Use: "multi-multi-error",
|
||||
Short: "This is a multi error inside a multi error",
|
||||
Handler: func(inv *serpent.Invocation) error {
|
||||
Handler: func(_ *serpent.Invocation) error {
|
||||
return errors.Join(
|
||||
xerrors.Errorf("parent error: %w", errorWithStackTrace()),
|
||||
errors.Join(
|
||||
@@ -100,7 +100,7 @@ func (RootCmd) errorExample() *serpent.Command {
|
||||
Required: true,
|
||||
Flag: "magic-word",
|
||||
Default: "",
|
||||
Value: serpent.Validate(&magicWord, func(value *serpent.String) error {
|
||||
Value: serpent.Validate(&magicWord, func(_ *serpent.String) error {
|
||||
return xerrors.Errorf("magic word is incorrect")
|
||||
}),
|
||||
},
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ fi
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cliui.Canceled
|
||||
return cliui.ErrCanceled
|
||||
}
|
||||
if extra != "" {
|
||||
if extAuth.TokenExtra == nil {
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestExternalAuth(t *testing.T) {
|
||||
inv.Stdout = pty.Output()
|
||||
waiter := clitest.StartWithWaiter(t, inv)
|
||||
pty.ExpectMatch("https://github.com")
|
||||
waiter.RequireIs(cliui.Canceled)
|
||||
waiter.RequireIs(cliui.ErrCanceled)
|
||||
})
|
||||
t.Run("SuccessWithToken", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ func (r *RootCmd) gitAskpass() *serpent.Command {
|
||||
cliui.Warn(inv.Stderr, "Coder was unable to handle this git request. The default git behavior will be used instead.",
|
||||
lines...,
|
||||
)
|
||||
return cliui.Canceled
|
||||
return cliui.ErrCanceled
|
||||
}
|
||||
return xerrors.Errorf("get git token: %w", err)
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGitAskpass(t *testing.T) {
|
||||
pty := ptytest.New(t)
|
||||
inv.Stderr = pty.Output()
|
||||
err := inv.Run()
|
||||
require.ErrorIs(t, err, cliui.Canceled)
|
||||
require.ErrorIs(t, err, cliui.ErrCanceled)
|
||||
pty.ExpectMatch("Nope!")
|
||||
})
|
||||
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ var fallbackIdentityFiles = strings.Join([]string{
|
||||
//
|
||||
// The extra arguments work without issue and lets us run the command
|
||||
// as-is without stripping out the excess (git-upload-pack 'coder/coder').
|
||||
func parseIdentityFilesForHost(ctx context.Context, args, env []string) (identityFiles []string, error error) {
|
||||
func parseIdentityFilesForHost(ctx context.Context, args, env []string) (identityFiles []string, err error) {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("get user home dir failed: %w", err)
|
||||
|
||||
+4
-7
@@ -42,6 +42,7 @@ func ttyWidth() int {
|
||||
// wrapTTY wraps a string to the width of the terminal, or 80 no terminal
|
||||
// is detected.
|
||||
func wrapTTY(s string) string {
|
||||
// #nosec G115 - Safe conversion as TTY width is expected to be within uint range
|
||||
return wordwrap.WrapString(s, uint(ttyWidth()))
|
||||
}
|
||||
|
||||
@@ -57,12 +58,8 @@ var usageTemplate = func() *template.Template {
|
||||
return template.Must(
|
||||
template.New("usage").Funcs(
|
||||
template.FuncMap{
|
||||
"version": func() string {
|
||||
return buildinfo.Version()
|
||||
},
|
||||
"wrapTTY": func(s string) string {
|
||||
return wrapTTY(s)
|
||||
},
|
||||
"version": buildinfo.Version,
|
||||
"wrapTTY": wrapTTY,
|
||||
"trimNewline": func(s string) string {
|
||||
return strings.TrimSuffix(s, "\n")
|
||||
},
|
||||
@@ -189,7 +186,7 @@ var usageTemplate = func() *template.Template {
|
||||
},
|
||||
"formatGroupDescription": func(s string) string {
|
||||
s = strings.ReplaceAll(s, "\n", "")
|
||||
s = s + "\n"
|
||||
s += "\n"
|
||||
s = wrapTTY(s)
|
||||
return s
|
||||
},
|
||||
|
||||
+6
-8
@@ -48,7 +48,7 @@ func promptFirstUsername(inv *serpent.Invocation) (string, error) {
|
||||
Text: "What " + pretty.Sprint(cliui.DefaultStyles.Field, "username") + " would you like?",
|
||||
Default: currentUser.Username,
|
||||
})
|
||||
if errors.Is(err, cliui.Canceled) {
|
||||
if errors.Is(err, cliui.ErrCanceled) {
|
||||
return "", nil
|
||||
}
|
||||
if err != nil {
|
||||
@@ -64,7 +64,7 @@ func promptFirstName(inv *serpent.Invocation) (string, error) {
|
||||
Default: "",
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, cliui.Canceled) {
|
||||
if errors.Is(err, cliui.ErrCanceled) {
|
||||
return "", nil
|
||||
}
|
||||
return "", err
|
||||
@@ -76,11 +76,9 @@ func promptFirstName(inv *serpent.Invocation) (string, error) {
|
||||
func promptFirstPassword(inv *serpent.Invocation) (string, error) {
|
||||
retry:
|
||||
password, err := cliui.Prompt(inv, cliui.PromptOptions{
|
||||
Text: "Enter a " + pretty.Sprint(cliui.DefaultStyles.Field, "password") + ":",
|
||||
Secret: true,
|
||||
Validate: func(s string) error {
|
||||
return userpassword.Validate(s)
|
||||
},
|
||||
Text: "Enter a " + pretty.Sprint(cliui.DefaultStyles.Field, "password") + ":",
|
||||
Secret: true,
|
||||
Validate: userpassword.Validate,
|
||||
})
|
||||
if err != nil {
|
||||
return "", xerrors.Errorf("specify password prompt: %w", err)
|
||||
@@ -508,7 +506,7 @@ func promptTrialInfo(inv *serpent.Invocation, fieldName string) (string, error)
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, cliui.Canceled) {
|
||||
if errors.Is(err, cliui.ErrCanceled) {
|
||||
return "", nil
|
||||
}
|
||||
return "", err
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ func (r *RootCmd) openVSCode() *serpent.Command {
|
||||
})
|
||||
if err != nil {
|
||||
if xerrors.Is(err, context.Canceled) {
|
||||
return cliui.Canceled
|
||||
return cliui.ErrCanceled
|
||||
}
|
||||
return xerrors.Errorf("agent: %w", err)
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func (r *RootCmd) openVSCode() *serpent.Command {
|
||||
// However, if no directory is set, the expanded directory will
|
||||
// not be set either.
|
||||
if workspaceAgent.Directory != "" {
|
||||
workspace, workspaceAgent, err = waitForAgentCond(ctx, client, workspace, workspaceAgent, func(a codersdk.WorkspaceAgent) bool {
|
||||
workspace, workspaceAgent, err = waitForAgentCond(ctx, client, workspace, workspaceAgent, func(_ codersdk.WorkspaceAgent) bool {
|
||||
return workspaceAgent.LifecycleState != codersdk.WorkspaceAgentLifecycleCreated
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -40,7 +40,7 @@ func validateRemoteForward(flag string) bool {
|
||||
return isRemoteForwardTCP(flag) || isRemoteForwardUnixSocket(flag)
|
||||
}
|
||||
|
||||
func parseRemoteForwardTCP(matches []string) (net.Addr, net.Addr, error) {
|
||||
func parseRemoteForwardTCP(matches []string) (local net.Addr, remote net.Addr, err error) {
|
||||
remotePort, err := strconv.Atoi(matches[1])
|
||||
if err != nil {
|
||||
return nil, nil, xerrors.Errorf("remote port is invalid: %w", err)
|
||||
@@ -69,7 +69,7 @@ func parseRemoteForwardTCP(matches []string) (net.Addr, net.Addr, error) {
|
||||
// parseRemoteForwardUnixSocket parses a remote forward flag. Note that
|
||||
// we don't verify that the local socket path exists because the user
|
||||
// may create it later. This behavior matches OpenSSH.
|
||||
func parseRemoteForwardUnixSocket(matches []string) (net.Addr, net.Addr, error) {
|
||||
func parseRemoteForwardUnixSocket(matches []string) (local net.Addr, remote net.Addr, err error) {
|
||||
remoteSocket := matches[1]
|
||||
localSocket := matches[2]
|
||||
|
||||
@@ -85,7 +85,7 @@ func parseRemoteForwardUnixSocket(matches []string) (net.Addr, net.Addr, error)
|
||||
return localAddr, remoteAddr, nil
|
||||
}
|
||||
|
||||
func parseRemoteForward(flag string) (net.Addr, net.Addr, error) {
|
||||
func parseRemoteForward(flag string) (local net.Addr, remote net.Addr, err error) {
|
||||
tcpMatches := remoteForwardRegexTCP.FindStringSubmatch(flag)
|
||||
|
||||
if len(tcpMatches) > 0 {
|
||||
|
||||
@@ -62,11 +62,9 @@ func (*RootCmd) resetPassword() *serpent.Command {
|
||||
}
|
||||
|
||||
password, err := cliui.Prompt(inv, cliui.PromptOptions{
|
||||
Text: "Enter new " + pretty.Sprint(cliui.DefaultStyles.Field, "password") + ":",
|
||||
Secret: true,
|
||||
Validate: func(s string) error {
|
||||
return userpassword.Validate(s)
|
||||
},
|
||||
Text: "Enter new " + pretty.Sprint(cliui.DefaultStyles.Field, "password") + ":",
|
||||
Secret: true,
|
||||
Validate: userpassword.Validate,
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("password prompt: %w", err)
|
||||
|
||||
+5
-5
@@ -171,15 +171,15 @@ func (r *RootCmd) RunWithSubcommands(subcommands []*serpent.Command) {
|
||||
code = exitErr.code
|
||||
err = exitErr.err
|
||||
}
|
||||
if errors.Is(err, cliui.Canceled) {
|
||||
//nolint:revive
|
||||
if errors.Is(err, cliui.ErrCanceled) {
|
||||
//nolint:revive,gocritic
|
||||
os.Exit(code)
|
||||
}
|
||||
f := PrettyErrorFormatter{w: os.Stderr, verbose: r.verbose}
|
||||
if err != nil {
|
||||
f.Format(err)
|
||||
}
|
||||
//nolint:revive
|
||||
//nolint:revive,gocritic
|
||||
os.Exit(code)
|
||||
}
|
||||
}
|
||||
@@ -891,7 +891,7 @@ func DumpHandler(ctx context.Context, name string) {
|
||||
|
||||
done:
|
||||
if sigStr == "SIGQUIT" {
|
||||
//nolint:revive
|
||||
//nolint:revive,gocritic
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -1045,7 +1045,7 @@ func formatMultiError(from string, multi []error, opts *formatOpts) string {
|
||||
prefix := fmt.Sprintf("%d. ", i+1)
|
||||
if len(prefix) < len(indent) {
|
||||
// Indent the prefix to match the indent
|
||||
prefix = prefix + strings.Repeat(" ", len(indent)-len(prefix))
|
||||
prefix += strings.Repeat(" ", len(indent)-len(prefix))
|
||||
}
|
||||
errStr = prefix + errStr
|
||||
// Now looks like
|
||||
|
||||
+2
-2
@@ -1764,9 +1764,9 @@ func parseTLSCipherSuites(ciphers []string) ([]tls.CipherSuite, error) {
|
||||
// hasSupportedVersion is a helper function that returns true if the list
|
||||
// of supported versions contains a version between min and max.
|
||||
// If the versions list is outside the min/max, then it returns false.
|
||||
func hasSupportedVersion(min, max uint16, versions []uint16) bool {
|
||||
func hasSupportedVersion(minVal, maxVal uint16, versions []uint16) bool {
|
||||
for _, v := range versions {
|
||||
if v >= min && v <= max {
|
||||
if v >= minVal && v <= maxVal {
|
||||
// If one version is in between min/max, return true.
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1701,6 +1701,7 @@ func TestServer(t *testing.T) {
|
||||
// Next, we instruct the same server to display the YAML config
|
||||
// and then save it.
|
||||
inv = inv.WithContext(testutil.Context(t, testutil.WaitMedium))
|
||||
//nolint:gocritic
|
||||
inv.Args = append(args, "--write-config")
|
||||
fi, err := os.OpenFile(testutil.TempFile(t, "", "coder-config-test-*"), os.O_WRONLY|os.O_CREATE, 0o600)
|
||||
require.NoError(t, err)
|
||||
|
||||
+1
-1
@@ -264,7 +264,7 @@ func (r *RootCmd) ssh() *serpent.Command {
|
||||
})
|
||||
if err != nil {
|
||||
if xerrors.Is(err, context.Canceled) {
|
||||
return cliui.Canceled
|
||||
return cliui.ErrCanceled
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
+1
-1
@@ -341,7 +341,7 @@ func TestSSH(t *testing.T) {
|
||||
|
||||
cmdDone := tGo(t, func() {
|
||||
err := inv.WithContext(ctx).Run()
|
||||
assert.ErrorIs(t, err, cliui.Canceled)
|
||||
assert.ErrorIs(t, err, cliui.ErrCanceled)
|
||||
})
|
||||
pty.ExpectMatch(wantURL)
|
||||
cancel()
|
||||
|
||||
+4
-3
@@ -147,12 +147,13 @@ func (r *RootCmd) templateEdit() *serpent.Command {
|
||||
autostopRequirementWeeks = template.AutostopRequirement.Weeks
|
||||
}
|
||||
|
||||
if len(autostartRequirementDaysOfWeek) == 1 && autostartRequirementDaysOfWeek[0] == "all" {
|
||||
switch {
|
||||
case len(autostartRequirementDaysOfWeek) == 1 && autostartRequirementDaysOfWeek[0] == "all":
|
||||
// Set it to every day of the week
|
||||
autostartRequirementDaysOfWeek = []string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}
|
||||
} else if !userSetOption(inv, "autostart-requirement-weekdays") {
|
||||
case !userSetOption(inv, "autostart-requirement-weekdays"):
|
||||
autostartRequirementDaysOfWeek = template.AutostartRequirement.DaysOfWeek
|
||||
} else if len(autostartRequirementDaysOfWeek) == 0 {
|
||||
case len(autostartRequirementDaysOfWeek) == 0:
|
||||
autostartRequirementDaysOfWeek = []string{}
|
||||
}
|
||||
|
||||
|
||||
@@ -723,6 +723,7 @@ func TestTemplatePush(t *testing.T) {
|
||||
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, templateVersion.ID)
|
||||
|
||||
// Test the cli command.
|
||||
//nolint:gocritic
|
||||
modifiedTemplateVariables := append(initialTemplateVariables,
|
||||
&proto.TemplateVariable{
|
||||
Name: "second_variable",
|
||||
@@ -792,6 +793,7 @@ func TestTemplatePush(t *testing.T) {
|
||||
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, templateVersion.ID)
|
||||
|
||||
// Test the cli command.
|
||||
//nolint:gocritic
|
||||
modifiedTemplateVariables := append(initialTemplateVariables,
|
||||
&proto.TemplateVariable{
|
||||
Name: "second_variable",
|
||||
@@ -839,6 +841,7 @@ func TestTemplatePush(t *testing.T) {
|
||||
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, templateVersion.ID)
|
||||
|
||||
// Test the cli command.
|
||||
//nolint:gocritic
|
||||
modifiedTemplateVariables := append(initialTemplateVariables,
|
||||
&proto.TemplateVariable{
|
||||
Name: "second_variable",
|
||||
@@ -905,6 +908,7 @@ func TestTemplatePush(t *testing.T) {
|
||||
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, templateVersion.ID)
|
||||
|
||||
// Test the cli command.
|
||||
//nolint:gocritic
|
||||
modifiedTemplateVariables := append(initialTemplateVariables,
|
||||
&proto.TemplateVariable{
|
||||
Name: "second_variable",
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ func parseCLISchedule(parts ...string) (*cron.Schedule, error) {
|
||||
func parseDuration(raw string) (time.Duration, error) {
|
||||
// If the user input a raw number, assume minutes
|
||||
if isDigit(raw) {
|
||||
raw = raw + "m"
|
||||
raw += "m"
|
||||
}
|
||||
d, err := time.ParseDuration(raw)
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ func (r *RootCmd) vscodeSSH() *serpent.Command {
|
||||
})
|
||||
if err != nil {
|
||||
if xerrors.Is(err, context.Canceled) {
|
||||
return cliui.Canceled
|
||||
return cliui.ErrCanceled
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user