network: Honor MANTLE_SSH_DIR
I plan to use this for cosa to make it a bit easier to log in
manually to instances created by `cosa kola`.  It will be set
to a predictable path rather than a dir in `/tmp` that one may
have to hunt down.
@@ -68,10 +68,16 @@ func NewSSHAgent(dialer Dialer) (*SSHAgent, error) {
return nil, err
}
- sockDir, err := ioutil.TempDir("", "mantle-ssh-")
+ var sockDir string
+ var ok bool
+ // This will be set by at least `coreos-assembler kola` since
+ // we have an implicit workdir.
+ if sockDir, ok = os.LookupEnv("MANTLE_SSH_DIR"); !ok {
+ sockDir, err = ioutil.TempDir("", "mantle-ssh-")
if err != nil {
return nil, err
}
+ }
// Use a similar naming scheme to ssh-agent
sockPath := fmt.Sprintf("%s/agent.%d", sockDir, os.Getpid())
