Skip to content

Commit 4962324

Browse files
authored
chore(cli): replace clibase with external coder/serpent (#12252)
1 parent bed2545 commit 4962324

File tree

185 files changed

+3555
-7006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+3555
-7006
lines changed

cli/agent.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ import (
2929
"github.com/coder/coder/v2/agent/agentproc"
3030
"github.com/coder/coder/v2/agent/reaper"
3131
"github.com/coder/coder/v2/buildinfo"
32-
"github.com/coder/coder/v2/cli/clibase"
3332
"github.com/coder/coder/v2/codersdk"
3433
"github.com/coder/coder/v2/codersdk/agentsdk"
34+
"github.com/coder/serpent"
3535
)
3636

37-
func (r *RootCmd) workspaceAgent() *clibase.Cmd {
37+
func (r *RootCmd) workspaceAgent() *serpent.Cmd {
3838
var (
3939
auth string
4040
logDir string
@@ -49,12 +49,12 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
4949
slogJSONPath string
5050
slogStackdriverPath string
5151
)
52-
cmd := &clibase.Cmd{
52+
cmd := &serpent.Cmd{
5353
Use: "agent",
5454
Short: `Starts the Coder workspace agent.`,
5555
// This command isn't useful to manually execute.
5656
Hidden: true,
57-
Handler: func(inv *clibase.Invocation) error {
57+
Handler: func(inv *serpent.Invocation) error {
5858
ctx, cancel := context.WithCancel(inv.Context())
5959
defer cancel()
6060

@@ -325,69 +325,69 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
325325
},
326326
}
327327

328-
cmd.Options = clibase.OptionSet{
328+
cmd.Options = serpent.OptionSet{
329329
{
330330
Flag: "auth",
331331
Default: "token",
332332
Description: "Specify the authentication type to use for the agent.",
333333
Env: "CODER_AGENT_AUTH",
334-
Value: clibase.StringOf(&auth),
334+
Value: serpent.StringOf(&auth),
335335
},
336336
{
337337
Flag: "log-dir",
338338
Default: os.TempDir(),
339339
Description: "Specify the location for the agent log files.",
340340
Env: "CODER_AGENT_LOG_DIR",
341-
Value: clibase.StringOf(&logDir),
341+
Value: serpent.StringOf(&logDir),
342342
},
343343
{
344344
Flag: "script-data-dir",
345345
Default: os.TempDir(),
346346
Description: "Specify the location for storing script data.",
347347
Env: "CODER_AGENT_SCRIPT_DATA_DIR",
348-
Value: clibase.StringOf(&scriptDataDir),
348+
Value: serpent.StringOf(&scriptDataDir),
349349
},
350350
{
351351
Flag: "pprof-address",
352352
Default: "127.0.0.1:6060",
353353
Env: "CODER_AGENT_PPROF_ADDRESS",
354-
Value: clibase.StringOf(&pprofAddress),
354+
Value: serpent.StringOf(&pprofAddress),
355355
Description: "The address to serve pprof.",
356356
},
357357
{
358358
Flag: "no-reap",
359359

360360
Env: "",
361361
Description: "Do not start a process reaper.",
362-
Value: clibase.BoolOf(&noReap),
362+
Value: serpent.BoolOf(&noReap),
363363
},
364364
{
365365
Flag: "ssh-max-timeout",
366366
// tcpip.KeepaliveIdleOption = 72h + 1min (forwardTCPSockOpts() in tailnet/conn.go)
367367
Default: "72h",
368368
Env: "CODER_AGENT_SSH_MAX_TIMEOUT",
369369
Description: "Specify the max timeout for a SSH connection, it is advisable to set it to a minimum of 60s, but no more than 72h.",
370-
Value: clibase.DurationOf(&sshMaxTimeout),
370+
Value: serpent.DurationOf(&sshMaxTimeout),
371371
},
372372
{
373373
Flag: "tailnet-listen-port",
374374
Default: "0",
375375
Env: "CODER_AGENT_TAILNET_LISTEN_PORT",
376376
Description: "Specify a static port for Tailscale to use for listening.",
377-
Value: clibase.Int64Of(&tailnetListenPort),
377+
Value: serpent.Int64Of(&tailnetListenPort),
378378
},
379379
{
380380
Flag: "prometheus-address",
381381
Default: "127.0.0.1:2112",
382382
Env: "CODER_AGENT_PROMETHEUS_ADDRESS",
383-
Value: clibase.StringOf(&prometheusAddress),
383+
Value: serpent.StringOf(&prometheusAddress),
384384
Description: "The bind address to serve Prometheus metrics.",
385385
},
386386
{
387387
Flag: "debug-address",
388388
Default: "127.0.0.1:2113",
389389
Env: "CODER_AGENT_DEBUG_ADDRESS",
390-
Value: clibase.StringOf(&debugAddress),
390+
Value: serpent.StringOf(&debugAddress),
391391
Description: "The bind address to serve a debug HTTP server.",
392392
},
393393
{
@@ -396,23 +396,23 @@ func (r *RootCmd) workspaceAgent() *clibase.Cmd {
396396
Flag: "log-human",
397397
Env: "CODER_AGENT_LOGGING_HUMAN",
398398
Default: "/dev/stderr",
399-
Value: clibase.StringOf(&slogHumanPath),
399+
Value: serpent.StringOf(&slogHumanPath),
400400
},
401401
{
402402
Name: "JSON Log Location",
403403
Description: "Output JSON logs to a given file.",
404404
Flag: "log-json",
405405
Env: "CODER_AGENT_LOGGING_JSON",
406406
Default: "",
407-
Value: clibase.StringOf(&slogJSONPath),
407+
Value: serpent.StringOf(&slogJSONPath),
408408
},
409409
{
410410
Name: "Stackdriver Log Location",
411411
Description: "Output Stackdriver compatible logs to a given file.",
412412
Flag: "log-stackdriver",
413413
Env: "CODER_AGENT_LOGGING_STACKDRIVER",
414414
Default: "",
415-
Value: clibase.StringOf(&slogStackdriverPath),
415+
Value: serpent.StringOf(&slogStackdriverPath),
416416
},
417417
}
418418

cli/autoupdate.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ import (
66

77
"golang.org/x/xerrors"
88

9-
"github.com/coder/coder/v2/cli/clibase"
109
"github.com/coder/coder/v2/cli/cliui"
1110
"github.com/coder/coder/v2/codersdk"
11+
"github.com/coder/serpent"
1212
)
1313

14-
func (r *RootCmd) autoupdate() *clibase.Cmd {
14+
func (r *RootCmd) autoupdate() *serpent.Cmd {
1515
client := new(codersdk.Client)
16-
cmd := &clibase.Cmd{
16+
cmd := &serpent.Cmd{
1717
Annotations: workspaceCommand,
1818
Use: "autoupdate <workspace> <always|never>",
1919
Short: "Toggle auto-update policy for a workspace",
20-
Middleware: clibase.Chain(
21-
clibase.RequireNArgs(2),
20+
Middleware: serpent.Chain(
21+
serpent.RequireNArgs(2),
2222
r.InitClient(client),
2323
),
24-
Handler: func(inv *clibase.Invocation) error {
24+
Handler: func(inv *serpent.Invocation) error {
2525
policy := strings.ToLower(inv.Args[1])
2626
err := validateAutoUpdatePolicy(policy)
2727
if err != nil {

cli/clibase/clibase.go

-80
This file was deleted.

0 commit comments

Comments
 (0)