|
| 1 | +package cli |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + |
| 7 | + "github.com/coder/coder/cli" |
| 8 | + |
| 9 | + "github.com/coder/coder/cli/clibase" |
| 10 | + "github.com/coder/coder/codersdk" |
| 11 | +) |
| 12 | + |
| 13 | +func (r *RootCmd) workspaceProxy() *clibase.Cmd { |
| 14 | + cmd := &clibase.Cmd{ |
| 15 | + Use: "workspace-proxy", |
| 16 | + Short: "Manage workspace proxies", |
| 17 | + Aliases: []string{"proxy"}, |
| 18 | + Hidden: true, |
| 19 | + Handler: func(inv *clibase.Invocation) error { |
| 20 | + return inv.Command.HelpHandler(inv) |
| 21 | + }, |
| 22 | + Children: []*clibase.Cmd{ |
| 23 | + r.proxyServer(), |
| 24 | + }, |
| 25 | + } |
| 26 | + |
| 27 | + return cmd |
| 28 | +} |
| 29 | + |
| 30 | +func (r *RootCmd) proxyServer() *clibase.Cmd { |
| 31 | + var ( |
| 32 | + // TODO: Remove options that we do not need |
| 33 | + cfg = new(codersdk.DeploymentValues) |
| 34 | + opts = cfg.Options() |
| 35 | + ) |
| 36 | + var _ = opts |
| 37 | + |
| 38 | + client := new(codersdk.Client) |
| 39 | + cmd := &clibase.Cmd{ |
| 40 | + Use: "server", |
| 41 | + Short: "Start a workspace proxy server", |
| 42 | + Middleware: clibase.Chain( |
| 43 | + cli.WriteConfigMW(cfg), |
| 44 | + cli.PrintDeprecatedOptions(), |
| 45 | + clibase.RequireNArgs(0), |
| 46 | + // We need a client to connect with the primary coderd instance. |
| 47 | + r.InitClient(client), |
| 48 | + ), |
| 49 | + Handler: func(inv *clibase.Invocation) error { |
| 50 | + // Main command context for managing cancellation of running |
| 51 | + // services. |
| 52 | + ctx, cancel := context.WithCancel(inv.Context()) |
| 53 | + defer cancel() |
| 54 | + var _ = ctx |
| 55 | + |
| 56 | + _, _ = fmt.Fprintf(inv.Stdout, "Not yet implemented\n") |
| 57 | + return nil |
| 58 | + }, |
| 59 | + } |
| 60 | + |
| 61 | + return cmd |
| 62 | +} |
0 commit comments