mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix: conform to stricter printf usage in Go 1.24 (#16330)
This commit is contained in:
committed by
GitHub
parent
967a3810f4
commit
9520da338e
+1
-1
@@ -977,7 +977,7 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
|
||||
isErr := strings.Contains(errorMessage, agentssh.BlockedFileTransferErrorMessage) ||
|
||||
strings.Contains(errorMessage, "EOF") ||
|
||||
strings.Contains(errorMessage, "Process exited with status 65")
|
||||
require.True(t, isErr, fmt.Sprintf("Message: "+errorMessage))
|
||||
require.True(t, isErr, "Message: "+errorMessage)
|
||||
}
|
||||
|
||||
t.Run("SFTP", func(t *testing.T) {
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ func (r *RootCmd) gitssh() *serpent.Command {
|
||||
if xerrors.As(err, &exitErr) && exitErr.ExitCode() == 255 {
|
||||
_, _ = fmt.Fprintln(inv.Stderr,
|
||||
"\n"+pretty.Sprintf(
|
||||
cliui.DefaultStyles.Wrap,
|
||||
cliui.DefaultStyles.Wrap, "%s",
|
||||
"Coder authenticates with "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+
|
||||
" using the public key below. All clones with SSH are authenticated automatically 🪄.")+"\n",
|
||||
)
|
||||
|
||||
+1
-1
@@ -209,7 +209,7 @@ func (r *RootCmd) login() *serpent.Command {
|
||||
|
||||
// nolint: nestif
|
||||
if !hasFirstUser {
|
||||
_, _ = fmt.Fprintf(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n")
|
||||
_, _ = fmt.Fprint(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n")
|
||||
|
||||
if username == "" {
|
||||
if !isTTYIn(inv) {
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ func (r *RootCmd) logout() *serpent.Command {
|
||||
errorString := strings.TrimRight(errorStringBuilder.String(), "\n")
|
||||
return xerrors.New("Failed to log out.\n" + errorString)
|
||||
}
|
||||
_, _ = fmt.Fprintf(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
|
||||
_, _ = fmt.Fprint(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
+5
-5
@@ -45,14 +45,14 @@ func (r *RootCmd) publickey() *serpent.Command {
|
||||
return xerrors.Errorf("create codersdk client: %w", err)
|
||||
}
|
||||
|
||||
cliui.Infof(inv.Stdout,
|
||||
cliui.Info(inv.Stdout,
|
||||
"This is your public key for using "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+" in "+
|
||||
"Coder. All clones with SSH will be authenticated automatically 🪄.",
|
||||
)
|
||||
cliui.Infof(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n")
|
||||
cliui.Infof(inv.Stdout, "Add to GitHub and GitLab:")
|
||||
cliui.Infof(inv.Stdout, "> https://github.com/settings/ssh/new")
|
||||
cliui.Infof(inv.Stdout, "> https://gitlab.com/-/profile/keys")
|
||||
cliui.Info(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n")
|
||||
cliui.Info(inv.Stdout, "Add to GitHub and GitLab:")
|
||||
cliui.Info(inv.Stdout, "> https://github.com/settings/ssh/new")
|
||||
cliui.Info(inv.Stdout, "> https://gitlab.com/-/profile/keys")
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
+1
-1
@@ -513,7 +513,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
|
||||
}
|
||||
|
||||
accessURL := vals.AccessURL.String()
|
||||
cliui.Infof(inv.Stdout, lipgloss.NewStyle().
|
||||
cliui.Info(inv.Stdout, lipgloss.NewStyle().
|
||||
Border(lipgloss.DoubleBorder()).
|
||||
Align(lipgloss.Center).
|
||||
Padding(0, 3).
|
||||
|
||||
@@ -76,7 +76,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
|
||||
for _, version := range versions {
|
||||
if version.Archived == archive {
|
||||
_, _ = fmt.Fprintln(
|
||||
inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb),
|
||||
inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb,
|
||||
)
|
||||
continue
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintln(
|
||||
inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now())),
|
||||
inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now()),
|
||||
)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -100,9 +100,9 @@ func (r *WorkspaceProxyReport) Run(ctx context.Context, opts *WorkspaceProxyRepo
|
||||
for _, err := range errs {
|
||||
switch r.Severity {
|
||||
case health.SeverityWarning, health.SeverityOK:
|
||||
r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, err))
|
||||
r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, "%s", err))
|
||||
case health.SeverityError:
|
||||
r.appendError(*health.Errorf(health.CodeProxyUnhealthy, err))
|
||||
r.appendError(*health.Errorf(health.CodeProxyUnhealthy, "%s", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ func TestWebsocketCloseMsg(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
msg := strings.Repeat("d", 255)
|
||||
trunc := httpapi.WebsocketCloseSprintf(msg)
|
||||
trunc := httpapi.WebsocketCloseSprintf("%s", msg)
|
||||
assert.Equal(t, len(trunc), 123)
|
||||
})
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestWebsocketCloseMsg(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
msg := strings.Repeat("こんにちは", 10)
|
||||
trunc := httpapi.WebsocketCloseSprintf(msg)
|
||||
trunc := httpapi.WebsocketCloseSprintf("%s", msg)
|
||||
assert.Equal(t, len(trunc), 123)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ func (r *RootCmd) proxyServer() *serpent.Command {
|
||||
httpClient.Transport = headerTransport
|
||||
|
||||
accessURL := cfg.AccessURL.String()
|
||||
cliui.Infof(inv.Stdout, lipgloss.NewStyle().
|
||||
cliui.Info(inv.Stdout, lipgloss.NewStyle().
|
||||
Border(lipgloss.DoubleBorder()).
|
||||
Align(lipgloss.Center).
|
||||
Padding(0, 3).
|
||||
|
||||
@@ -78,7 +78,7 @@ func (s *server) Plan(
|
||||
|
||||
e := s.executor(sess.WorkDirectory, database.ProvisionerJobTimingStagePlan)
|
||||
if err := e.checkMinVersion(ctx); err != nil {
|
||||
return provisionersdk.PlanErrorf(err.Error())
|
||||
return provisionersdk.PlanErrorf("%s", err.Error())
|
||||
}
|
||||
logTerraformEnvVars(sess)
|
||||
|
||||
@@ -113,7 +113,6 @@ func (s *server) Plan(
|
||||
initTimings.ingest(createInitTimingsEvent(timingInitStart))
|
||||
|
||||
err = e.init(ctx, killCtx, sess)
|
||||
|
||||
if err != nil {
|
||||
initTimings.ingest(createInitTimingsEvent(timingInitErrored))
|
||||
|
||||
@@ -168,7 +167,7 @@ func (s *server) Plan(
|
||||
request.Metadata.GetWorkspaceTransition() == proto.WorkspaceTransition_DESTROY,
|
||||
)
|
||||
if err != nil {
|
||||
return provisionersdk.PlanErrorf(err.Error())
|
||||
return provisionersdk.PlanErrorf("%s", err.Error())
|
||||
}
|
||||
|
||||
// Prepend init timings since they occur prior to plan timings.
|
||||
@@ -189,7 +188,7 @@ func (s *server) Apply(
|
||||
|
||||
e := s.executor(sess.WorkDirectory, database.ProvisionerJobTimingStageApply)
|
||||
if err := e.checkMinVersion(ctx); err != nil {
|
||||
return provisionersdk.ApplyErrorf(err.Error())
|
||||
return provisionersdk.ApplyErrorf("%s", err.Error())
|
||||
}
|
||||
logTerraformEnvVars(sess)
|
||||
|
||||
|
||||
@@ -252,6 +252,7 @@ func (e *outExpecter) Peek(ctx context.Context, n int) []byte {
|
||||
return slices.Clone(out)
|
||||
}
|
||||
|
||||
//nolint:govet // We don't care about conforming to ReadRune() (rune, int, error).
|
||||
func (e *outExpecter) ReadRune(ctx context.Context) rune {
|
||||
e.t.Helper()
|
||||
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ func NewTunnel(
|
||||
return nil, err
|
||||
}
|
||||
t := &Tunnel{
|
||||
// nolint: govet // safe to copy the locks here because we haven't started the speaker
|
||||
//nolint:govet // safe to copy the locks here because we haven't started the speaker
|
||||
speaker: *(s),
|
||||
ctx: ctx,
|
||||
logger: logger,
|
||||
|
||||
Reference in New Issue
Block a user