Skip to content

Commit 27ab0d9

Browse files
authored
refactor(enterprise/cli): remove provisionerd from slim binary (#9488)
This change saves 8 MB in the slim binary. Ref: #9380
1 parent 19d7da3 commit 27ab0d9

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

enterprise/cli/provisionerdaemons.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !slim
2+
13
package cli
24

35
import (
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//go:build slim
2+
3+
package cli
4+
5+
import (
6+
"github.com/coder/coder/v2/cli/clibase"
7+
)
8+
9+
func (r *RootCmd) provisionerDaemons() *clibase.Cmd {
10+
cmd := &clibase.Cmd{
11+
Use: "provisionerd",
12+
Short: "Manage provisioner daemons",
13+
// We accept RawArgs so all commands and flags are accepted.
14+
RawArgs: true,
15+
Hidden: true,
16+
Handler: func(inv *clibase.Invocation) error {
17+
slimUnsupported(inv.Stderr, "coder provisionerd")
18+
return nil
19+
},
20+
}
21+
22+
return cmd
23+
}

enterprise/cli/proxyserver_slim.go

+1-14
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
package cli
44

55
import (
6-
"fmt"
7-
"io"
8-
"os"
9-
106
"github.com/coder/coder/v2/cli/clibase"
11-
"github.com/coder/coder/v2/cli/cliui"
127
)
138

149
func (r *RootCmd) proxyServer() *clibase.Cmd {
@@ -20,18 +15,10 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
2015
RawArgs: true,
2116
Hidden: true,
2217
Handler: func(inv *clibase.Invocation) error {
23-
serverUnsupported(inv.Stderr)
18+
slimUnsupported(inv.Stderr, "workspace-proxy server")
2419
return nil
2520
},
2621
}
2722

2823
return root
2924
}
30-
31-
func serverUnsupported(w io.Writer) {
32-
_, _ = fmt.Fprintf(w, "You are using a 'slim' build of Coder, which does not support the %s subcommand.\n", cliui.DefaultStyles.Code.Render("server"))
33-
_, _ = fmt.Fprintln(w, "")
34-
_, _ = fmt.Fprintln(w, "Please use a build of Coder from GitHub releases:")
35-
_, _ = fmt.Fprintln(w, " https://github.com/coder/coder/releases")
36-
os.Exit(1)
37-
}

enterprise/cli/root.go

+16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package cli
22

33
import (
4+
"fmt"
5+
"io"
6+
"os"
7+
48
"github.com/coder/coder/v2/cli"
59
"github.com/coder/coder/v2/cli/clibase"
10+
"github.com/coder/coder/v2/cli/cliui"
611
)
712

813
type RootCmd struct {
@@ -24,3 +29,14 @@ func (r *RootCmd) EnterpriseSubcommands() []*clibase.Cmd {
2429
all := append(r.Core(), r.enterpriseOnly()...)
2530
return all
2631
}
32+
33+
//nolint:unused
34+
func slimUnsupported(w io.Writer, cmd string) {
35+
_, _ = fmt.Fprintf(w, "You are using a 'slim' build of Coder, which does not support the %s subcommand.\n", cliui.DefaultStyles.Code.Render(cmd))
36+
_, _ = fmt.Fprintln(w, "")
37+
_, _ = fmt.Fprintln(w, "Please use a build of Coder from GitHub releases:")
38+
_, _ = fmt.Fprintln(w, " https://github.com/coder/coder/releases")
39+
40+
//nolint:revive
41+
os.Exit(1)
42+
}

0 commit comments

Comments
 (0)