aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Cholewiński <harry666t@gmail.com>2018-01-04 21:15:11 +0100
committerKamil Cholewiński <harry666t@gmail.com>2018-01-04 21:16:15 +0100
commit5cde7abf5e6e99bf2d89602f0c8e5458fd2926d5 (patch)
tree7b3b4917737f7dcf78139628b3d67554be68f3be
parentbdd6fe797625f3b5a8adba831e8310c118e5147d (diff)
downloadjudo-5cde7abf5e6e99bf2d89602f0c8e5458fd2926d5.zip
judo-5cde7abf5e6e99bf2d89602f0c8e5458fd2926d5.tar.gz
judo-5cde7abf5e6e99bf2d89602f0c8e5458fd2926d5.tar.bz2
Rename Host.tmpdir -> Host.workdir
-rw-r--r--host.go31
-rw-r--r--transport.go2
2 files changed, 18 insertions, 15 deletions
diff --git a/host.go b/host.go
index 76fd2b3..07ed2a5 100644
--- a/host.go
+++ b/host.go
@@ -9,13 +9,13 @@ import (
// Host represents a single host (invocation target)
type Host struct {
- Name string
- Env map[string]string
- groups []string
- tmpdir string
- cancel chan bool
- master *Proc
- logger *log.Logger
+ Name string
+ Env map[string]string
+ groups []string
+ workdir string
+ cancel chan bool
+ master *Proc
+ logger *log.Logger
}
// NewHost creates a new Host struct with default values.
@@ -45,15 +45,15 @@ func (host *Host) SendRemoteAndRun(job *Job) (err error) {
// make cozy
err = host.SSH(job, "mkdir -p $HOME/.judo")
- tmpdir, err := host.SSHRead(job, "TMPDIR=$HOME/.judo mktemp -d")
+ workdir, err := host.SSHRead(job, "TMPDIR=$HOME/.judo mktemp -d")
if err != nil {
return err
}
- host.tmpdir = tmpdir
+ host.workdir = workdir
cleanup := func() error {
- host.tmpdir = ""
- return host.SSH(job, fmt.Sprintf("rm -r %s", tmpdir))
+ host.workdir = ""
+ return host.SSH(job, fmt.Sprintf("rm -r %s", workdir))
}
// ensure cleanup
@@ -67,15 +67,18 @@ func (host *Host) SendRemoteAndRun(job *Job) (err error) {
}()
// push files to remote
- host.pushFiles(job, job.Script.fname, tmpdir)
+ host.pushFiles(job, job.Script.fname, workdir)
// are we in dirmode?
var remoteCommand string
if !job.Script.dirmode {
- remoteCommand = path.Join(tmpdir, path.Base(job.Script.fname))
+ remoteCommand = path.Join(
+ workdir,
+ path.Base(job.Script.fname),
+ )
} else {
remoteCommand = path.Join(
- tmpdir,
+ workdir,
path.Base(job.Script.fname),
"script",
)
diff --git a/transport.go b/transport.go
index 7971906..b979381 100644
--- a/transport.go
+++ b/transport.go
@@ -46,7 +46,7 @@ func shquote(s string) string {
func (host *Host) startSSH(job *Job, command string) (proc *Proc, err error) {
sshArgs := []string{host.Name}
- sshArgs = append(sshArgs, []string{"cd", host.tmpdir, "&&"}...)
+ sshArgs = append(sshArgs, []string{"cd", host.workdir, "&&"}...)
sshArgs = append(sshArgs, []string{"env"}...)
for key, value := range host.Env {
sshArgs = append(sshArgs, fmt.Sprintf("%s=%s", key, value))