File tree 4 files changed +16
-4
lines changed
4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ type DatabaseOptions struct {
31
31
Mysql string
32
32
}
33
33
34
+ type EnvironmentVar struct {
35
+ Name string
36
+ Value string
37
+ }
38
+
34
39
type Database struct {
35
40
Type string
36
41
Schema string
@@ -64,6 +69,7 @@ type Execution struct {
64
69
Type string
65
70
Command YamlStringArray
66
71
Workdir string
72
+ Environment []EnvironmentVar
67
73
Options struct {
68
74
}
69
75
}
Original file line number Diff line number Diff line change 9
9
10
10
func (database * Database ) ApplyDefaults (server * Server ) {
11
11
// set default connection if not set
12
- if (commandbuilder. Connection {}) == database .Connection {
12
+ if database .Connection . IsEmpty () {
13
13
database .Connection = server .Connection
14
14
}
15
15
}
Original file line number Diff line number Diff line change @@ -35,13 +35,20 @@ func (execution *Execution) commandBuilder(server *Server) []interface{} {
35
35
case "local" :
36
36
connection = commandbuilder.Connection {Type :"local" }
37
37
case "remote" :
38
- connection = server .Connection
38
+ connection = server .Connection . Clone ()
39
39
}
40
40
41
+ // set working directory
41
42
if execution .Workdir != "" {
42
43
connection .WorkDir = execution .Workdir
43
44
}
44
45
46
+ // set environment
47
+ connection .Environment = map [string ]string {}
48
+ for _ , val := range execution .Environment {
49
+ connection .Environment [val .Name ] = val .Value
50
+ }
51
+
45
52
if len (execution .Command .Multi ) >= 1 {
46
53
// multi element command (use safer quoting)
47
54
return connection .ShellCommandBuilder (execution .Command .Multi ... )
Original file line number Diff line number Diff line change @@ -3,12 +3,11 @@ package sync
3
3
import (
4
4
"fmt"
5
5
"strings"
6
- "github.com/webdevops/go-shell/commandbuilder"
7
6
)
8
7
9
8
func (filesystem * Filesystem ) ApplyDefaults (server * Server ) {
10
9
// set default connection if not set
11
- if (commandbuilder. Connection {}) == filesystem .Connection {
10
+ if filesystem .Connection . IsEmpty () {
12
11
filesystem .Connection = server .Connection
13
12
}
14
13
You can’t perform that action at this time.
0 commit comments