()
| 114 | } |
| 115 | |
| 116 | func (r *RootCmd) ssh() *serpent.Command { |
| 117 | var ( |
| 118 | stdio bool |
| 119 | tty bool |
| 120 | hostPrefix string |
| 121 | hostnameSuffix string |
| 122 | forceNewTunnel bool |
| 123 | forwardAgent bool |
| 124 | forwardGPG bool |
| 125 | identityAgent string |
| 126 | wsPollInterval time.Duration |
| 127 | waitEnum string |
| 128 | noWait bool |
| 129 | logDirPath string |
| 130 | remoteForwards []string |
| 131 | env []string |
| 132 | usageApp string |
| 133 | disableAutostart bool |
| 134 | networkInfoDir string |
| 135 | networkInfoInterval time.Duration |
| 136 | |
| 137 | containerName string |
| 138 | containerUser string |
| 139 | ) |
| 140 | cmd := &serpent.Command{ |
| 141 | Annotations: workspaceCommand, |
| 142 | Use: "ssh <workspace> [command]", |
| 143 | Short: "Start a shell into a workspace or run a command", |
| 144 | Long: "This command does not have full parity with the standard SSH command. For users who need the full functionality of SSH, create an ssh configuration with `coder config-ssh`.\n\n" + |
| 145 | FormatExamples( |
| 146 | Example{ |
| 147 | Description: "Use `--` to separate and pass flags directly to the command executed via SSH.", |
| 148 | Command: "coder ssh <workspace> -- ls -la", |
| 149 | }, |
| 150 | ), |
| 151 | Middleware: serpent.Chain( |
| 152 | // Require at least one arg for the workspace name |
| 153 | func(next serpent.HandlerFunc) serpent.HandlerFunc { |
| 154 | return func(i *serpent.Invocation) error { |
| 155 | got := len(i.Args) |
| 156 | if got < 1 { |
| 157 | return xerrors.New("expected the name of a workspace") |
| 158 | } |
| 159 | |
| 160 | return next(i) |
| 161 | } |
| 162 | }, |
| 163 | ), |
| 164 | CompletionHandler: func(inv *serpent.Invocation) []string { |
| 165 | client, err := r.InitClient(inv) |
| 166 | if err != nil { |
| 167 | return []string{} |
| 168 | } |
| 169 | |
| 170 | res, err := client.Workspaces(inv.Context(), codersdk.WorkspaceFilter{ |
| 171 | Owner: codersdk.Me, |
| 172 | }) |
| 173 | if err != nil { |
no test coverage detected