Skip to content

Commit 28324ae

Browse files
committed
use clearer args without vararg
1 parent 279f4a4 commit 28324ae

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

cli/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (r *RootCmd) Core() []*clibase.Cmd {
118118
}
119119

120120
func (r *RootCmd) AGPL() []*clibase.Cmd {
121-
all := append(r.Core(), r.Server( /* Do not import coderd here. */ ))
121+
all := append(r.Core(), r.Server( /* Do not import coderd here. */ nil))
122122
return all
123123
}
124124

cli/server.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,13 @@ func enablePrometheus(
305305
), nil
306306
}
307307

308-
func (r *RootCmd) Server(optionalNewAPI ...func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *clibase.Cmd {
309-
if len(optionalNewAPI) == 0 {
310-
optionalNewAPI = append(optionalNewAPI, func(_ context.Context, o *coderd.Options) (*coderd.API, io.Closer, error) {
308+
func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *clibase.Cmd {
309+
if newAPI == nil {
310+
newAPI = func(_ context.Context, o *coderd.Options) (*coderd.API, io.Closer, error) {
311311
api := coderd.New(o)
312312
return api, api, nil
313-
})
313+
}
314314
}
315-
newAPI := optionalNewAPI[0]
316315

317316
var (
318317
vals = new(codersdk.DeploymentValues)

cli/server_slim.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/coder/coder/v2/cli/cliui"
1212
)
1313

14-
func (r *RootCmd) Server() *clibase.Cmd {
14+
func (r *RootCmd) Server(_ func()) *clibase.Cmd {
1515
root := &clibase.Cmd{
1616
Use: "server",
1717
Short: "Start a Coder server",

enterprise/cli/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type RootCmd struct {
1111

1212
func (r *RootCmd) enterpriseOnly() []*clibase.Cmd {
1313
return []*clibase.Cmd{
14-
r.Server(),
14+
r.Server(nil),
1515
r.workspaceProxy(),
1616
r.features(),
1717
r.licenses(),

enterprise/cli/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
agplcoderd "github.com/coder/coder/v2/coderd"
2626
)
2727

28-
func (r *RootCmd) Server() *clibase.Cmd {
28+
func (r *RootCmd) Server(_ func()) *clibase.Cmd {
2929
cmd := r.RootCmd.Server(func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, io.Closer, error) {
3030
if options.DeploymentValues.DERP.Server.RelayURL.String() != "" {
3131
_, err := url.Parse(options.DeploymentValues.DERP.Server.RelayURL.String())

0 commit comments

Comments
 (0)