diff options
| author | Shulhan <ms@kilabit.info> | 2019-06-02 10:15:08 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-06-03 01:57:15 +0700 |
| commit | 04646412490f056157eff2e0f5b008db8e332919 (patch) | |
| tree | 1a08966d74c15d0a9e2d4c8fcf1122ff6dcabf8e | |
| parent | c335a55f3017de4a82b59c8305268c1a69653f82 (diff) | |
| download | pakakeh.go-04646412490f056157eff2e0f5b008db8e332919.tar.xz | |
ssh: add field Environments in client's config
The field Environments contains system environment variables that will
be passed to Execute.
| -rw-r--r-- | lib/ssh/client.go | 4 | ||||
| -rw-r--r-- | lib/ssh/clientconfig.go | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/ssh/client.go b/lib/ssh/client.go index 4a83bd98..7da0da45 100644 --- a/lib/ssh/client.go +++ b/lib/ssh/client.go @@ -80,6 +80,10 @@ func (cl *Client) Execute(cmd string) (err error) { sess.Stdout = os.Stdout sess.Stderr = os.Stderr + for k, v := range cl.cfg.Environments { + sess.Setenv(k, v) + } + err = sess.Run(cmd) if err != nil { err = fmt.Errorf("ssh: Run %q: %s", cmd, err.Error()) diff --git a/lib/ssh/clientconfig.go b/lib/ssh/clientconfig.go index 222af8e8..092d1bca 100644 --- a/lib/ssh/clientconfig.go +++ b/lib/ssh/clientconfig.go @@ -17,6 +17,10 @@ import ( // environment where the SSH program started. // type ClientConfig struct { + // Environments contains system environment variables that will be + // passed to Execute(). + Environments map[string]string + // WorkingDir contains the directory where the SSH client started. // This value is required when client want to copy file from/to // remote. |
