diff options
| author | Shulhan <ms@kilabit.info> | 2021-04-04 05:35:50 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-04-04 05:36:11 +0700 |
| commit | a79aeccc6bbdbb93cfcc59930e90af35aa993dab (patch) | |
| tree | e696b7e476f7991da8e85f9cab95b0c939bb1216 | |
| parent | 6770cd3062f8d3a23213eb95dd05cbc5bb03a26c (diff) | |
| download | awwan-a79aeccc6bbdbb93cfcc59930e90af35aa993dab.tar.xz | |
all: do not load SSH config if command mode is "local"
If the mode is local there is no need to parse and load the SSH config,
since the command to be executed will run on local machine anyway.
| -rw-r--r-- | command.go | 2 | ||||
| -rw-r--r-- | environment.go | 10 |
2 files changed, 7 insertions, 5 deletions
@@ -64,7 +64,7 @@ func NewCommand(mode, scriptPath string, startAt, endAt int) (cmd *Command, err scriptEnd: endAt, } - cmd.env, err = newEnvironment(scriptPath) + cmd.env, err = newEnvironment(mode, scriptPath) if err != nil { return nil, fmt.Errorf("%s: %w", logp, err) } diff --git a/environment.go b/environment.go index 33912f9..f2ab43a 100644 --- a/environment.go +++ b/environment.go @@ -42,7 +42,7 @@ type environment struct { // // newEnvironment create and initialize new environment from the script path. // -func newEnvironment(scriptPath string) (env *environment, err error) { +func newEnvironment(mode, scriptPath string) (env *environment, err error) { logp := "newEnvironment" env = &environment{} @@ -64,9 +64,11 @@ func newEnvironment(scriptPath string) (env *environment, err error) { return nil, fmt.Errorf("%s: %w", logp, err) } - err = env.loadAllSSHConfig(paths) - if err != nil { - return nil, fmt.Errorf("%s: %w", logp, err) + if mode == modePlay { + err = env.loadAllSSHConfig(paths) + if err != nil { + return nil, fmt.Errorf("%s: %w", logp, err) + } } rand.Seed(time.Now().Unix()) |
