refactor(cli): avoid importing coderd in slim server (#9483)

This small change removes 11 MB from the slim binary size.

Ref: #9380
This commit is contained in:
Mathias Fredriksson
2023-09-01 13:32:21 +00:00
committed by GitHub
parent 5d7a77911e
commit f1f9cb030d
6 changed files with 12 additions and 31 deletions
+1 -1
View File
@@ -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(),
+2 -2
View File
@@ -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 {
-20
View File
@@ -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
}