aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-04-04 05:35:50 +0700
committerShulhan <ms@kilabit.info>2021-04-04 05:36:11 +0700
commita79aeccc6bbdbb93cfcc59930e90af35aa993dab (patch)
treee696b7e476f7991da8e85f9cab95b0c939bb1216
parent6770cd3062f8d3a23213eb95dd05cbc5bb03a26c (diff)
downloadawwan-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.go2
-rw-r--r--environment.go10
2 files changed, 7 insertions, 5 deletions
diff --git a/command.go b/command.go
index 74eaae3..e803a93 100644
--- a/command.go
+++ b/command.go
@@ -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())