MCPcopy Index your code
hub / github.com/coder/coder / configSSH

Method configSSH

cli/configssh.go:230–574  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

228}
229
230func (r *RootCmd) configSSH() *serpent.Command {
231 var (
232 sshConfigFile string
233 sshConfigOpts sshConfigOptions
234 usePreviousOpts bool
235 dryRun bool
236 coderCliPath string
237 )
238 cmd := &serpent.Command{
239 Annotations: workspaceCommand,
240 Use: "config-ssh",
241 Short: "Add an SSH Host entry for your workspaces \"ssh workspace.coder\"",
242 Long: FormatExamples(
243 Example{
244 Description: "You can use -o (or --ssh-option) so set SSH options to be used for all your workspaces",
245 Command: "coder config-ssh -o ForwardAgent=yes",
246 },
247 Example{
248 Description: "You can use --dry-run (or -n) to see the changes that would be made",
249 Command: "coder config-ssh --dry-run",
250 },
251 ),
252 Middleware: serpent.Chain(
253 serpent.RequireNArgs(0),
254 ),
255 Handler: func(inv *serpent.Invocation) error {
256 client, err := r.InitClient(inv)
257 if err != nil {
258 return err
259 }
260
261 ctx := inv.Context()
262
263 if sshConfigOpts.waitEnum != "auto" && sshConfigOpts.skipProxyCommand {
264 // The wait option is applied to the ProxyCommand. If the user
265 // specifies skip-proxy-command, then wait cannot be applied.
266 return xerrors.Errorf("cannot specify both --skip-proxy-command and --wait")
267 }
268 sshConfigOpts.header = r.header
269 sshConfigOpts.headerCommand = r.headerCommand
270
271 // Talk to the API early to prevent the version mismatch
272 // warning from being printed in the middle of a prompt.
273 // This is needed because the asynchronous requests issued
274 // by sshPrepareWorkspaceConfigs may otherwise trigger the
275 // warning at any time.
276 _, _ = client.BuildInfo(ctx)
277
278 out := inv.Stdout
279 if dryRun {
280 // Print everything except diff to stderr so
281 // that it's possible to capture the diff.
282 out = inv.Stderr
283 }
284
285 coderBinary := coderCliPath
286 if coderBinary == "" {
287 coderBinary, err = currentBinPath(out)

Callers 1

CoreSubcommandsMethod · 0.95

Calls 15

InitClientMethod · 0.95
createConfigMethod · 0.95
asListMethod · 0.95
StatusCodeMethod · 0.95
ParseSSHConfigOptionFunction · 0.92
PromptFunction · 0.92
SkipPromptOptionFunction · 0.92
FormatExamplesFunction · 0.85
currentBinPathFunction · 0.85
sshConfigGetCoderSectionFunction · 0.85

Tested by

no test coverage detected