MCPcopy Create free account
hub / github.com/DBCDK/morph / CmdContext

Method CmdContext

ssh/ssh.go:60–76  ·  view source on GitHub ↗
(ctx context.Context, host Host, parts ...string)

Source from the content-addressed store, hash-verified

58}
59
60func (sshCtx *SSHContext) CmdContext(ctx context.Context, host Host, parts ...string) (*exec.Cmd, error) {
61
62 var err error
63 if parts, err = valCommand(parts); err != nil {
64 return nil, err
65 }
66
67 if parts[0] == "sudo" {
68 return sshCtx.SudoCmdContext(ctx, host, parts...)
69 }
70
71 cmd, cmdArgs := sshCtx.sshArgs(host, nil)
72 cmdArgs = append(cmdArgs, parts...)
73
74 command := exec.CommandContext(ctx, cmd, cmdArgs...)
75 return command, nil
76}
77
78func (ctx *SSHContext) sshArgs(host Host, transfer *FileTransfer) (cmd string, args []string) {
79 if transfer != nil {

Callers 4

CmdMethod · 0.95
CmdInteractiveMethod · 0.95
GetBootIDMethod · 0.95
RunMethod · 0.80

Calls 3

SudoCmdContextMethod · 0.95
sshArgsMethod · 0.95
valCommandFunction · 0.85

Tested by

no test coverage detected