diff --git a/cli/root.go b/cli/root.go index 3ab2f0d7f33b9..3d0daafbfa7e9 100644 --- a/cli/root.go +++ b/cli/root.go @@ -35,7 +35,6 @@ import ( "github.com/coder/coder/v2/cli/clibase" "github.com/coder/coder/v2/cli/cliui" "github.com/coder/coder/v2/cli/config" - "github.com/coder/coder/v2/coderd" "github.com/coder/coder/v2/coderd/gitauth" "github.com/coder/coder/v2/coderd/telemetry" "github.com/coder/coder/v2/codersdk" @@ -119,10 +118,7 @@ func (r *RootCmd) Core() []*clibase.Cmd { } func (r *RootCmd) AGPL() []*clibase.Cmd { - all := append(r.Core(), r.Server(func(_ context.Context, o *coderd.Options) (*coderd.API, io.Closer, error) { - api := coderd.New(o) - return api, api, nil - })) + all := append(r.Core(), r.Server( /* Do not import coderd here. */ nil)) return all } diff --git a/cli/server.go b/cli/server.go index 66cc22086418c..683d8aec58fb9 100644 --- a/cli/server.go +++ b/cli/server.go @@ -306,6 +306,13 @@ func enablePrometheus( } func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *clibase.Cmd { + if newAPI == nil { + newAPI = func(_ context.Context, o *coderd.Options) (*coderd.API, io.Closer, error) { + api := coderd.New(o) + return api, api, nil + } + } + var ( vals = new(codersdk.DeploymentValues) opts = vals.Options() diff --git a/cli/server_slim.go b/cli/server_slim.go index f5f17794f3f56..fadb703cc6466 100644 --- a/cli/server_slim.go +++ b/cli/server_slim.go @@ -3,17 +3,15 @@ package cli import ( - "context" "fmt" "io" "os" "github.com/coder/coder/v2/cli/clibase" "github.com/coder/coder/v2/cli/cliui" - "github.com/coder/coder/v2/coderd" ) -func (r *RootCmd) Server(_ func(context.Context, *coderd.Options) (*coderd.API, io.Closer, error)) *clibase.Cmd { +func (r *RootCmd) Server(_ func()) *clibase.Cmd { root := &clibase.Cmd{ Use: "server", Short: "Start a Coder server", diff --git a/enterprise/cli/root.go b/enterprise/cli/root.go index 9f7bfb9039683..360582a3e5193 100644 --- a/enterprise/cli/root.go +++ b/enterprise/cli/root.go @@ -11,7 +11,7 @@ type RootCmd struct { func (r *RootCmd) enterpriseOnly() []*clibase.Cmd { return []*clibase.Cmd{ - r.server(), + r.Server(nil), r.workspaceProxy(), r.features(), r.licenses(), diff --git a/enterprise/cli/server.go b/enterprise/cli/server.go index 3801d2208f3a6..021b66f2f7a60 100644 --- a/enterprise/cli/server.go +++ b/enterprise/cli/server.go @@ -25,8 +25,8 @@ import ( agplcoderd "github.com/coder/coder/v2/coderd" ) -func (r *RootCmd) server() *clibase.Cmd { - cmd := r.Server(func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, io.Closer, error) { +func (r *RootCmd) Server(_ func()) *clibase.Cmd { + cmd := r.RootCmd.Server(func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, io.Closer, error) { if options.DeploymentValues.DERP.Server.RelayURL.String() != "" { _, err := url.Parse(options.DeploymentValues.DERP.Server.RelayURL.String()) if err != nil { diff --git a/enterprise/cli/server_slim.go b/enterprise/cli/server_slim.go deleted file mode 100644 index a0e9800ed760f..0000000000000 --- a/enterprise/cli/server_slim.go +++ /dev/null @@ -1,20 +0,0 @@ -//go:build slim - -package cli - -import ( - "context" - "io" - - "golang.org/x/xerrors" - - "github.com/coder/coder/v2/cli/clibase" - agplcoderd "github.com/coder/coder/v2/coderd" -) - -func (r *RootCmd) server() *clibase.Cmd { - cmd := r.Server(func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, io.Closer, error) { - return nil, nil, xerrors.Errorf("slim build does not support `coder server`") - }) - return cmd -}