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

Method MakeTempFile

ssh/ssh.go:302–322  ·  view source on GitHub ↗
(host Host)

Source from the content-addressed store, hash-verified

300}
301
302func (ctx *SSHContext) MakeTempFile(host Host) (path string, err error) {
303 cmd, _ := ctx.Cmd(host, "mktemp")
304
305 var stdout bytes.Buffer
306 var stderr bytes.Buffer
307 cmd.Stdout = &stdout
308 cmd.Stderr = &stderr
309
310 err = cmd.Run()
311 if err != nil {
312 errorMessage := fmt.Sprintf(
313 "Error on remote host %s (%s):\nCouldn't create temporary file using mktemp\n\nOriginal error:\n%s",
314 host.GetName(), host.GetTargetHost(), stderr.String(),
315 )
316 return "", errors.New(errorMessage)
317 }
318
319 tempFile := strings.TrimSpace(stdout.String())
320
321 return tempFile, nil
322}
323
324func (ctx *SSHContext) UploadFile(host Host, source string, destination string) (err error) {
325 c, parts := ctx.sshArgs(host, &FileTransfer{

Callers

nothing calls this directly

Calls 5

CmdMethod · 0.95
StringMethod · 0.80
RunMethod · 0.65
GetNameMethod · 0.65
GetTargetHostMethod · 0.65

Tested by

no test coverage detected