Skip to content

Commit fef613f

Browse files
committed
Split execStartup and execFinish
1 parent 55304a5 commit fef613f

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

sync/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ type Execution struct {
6363
Type string
6464
Command YamlStringArray
6565
Workdir string
66-
When string
6766
}
6867

6968
type Server struct {
7069
Path string
7170
Connection Connection
7271
Filesystem []Filesystem
7372
Database []Database
74-
Exec []Execution
73+
ExecStartup []Execution `yaml:"exec-startup"`
74+
ExecFinish []Execution `yaml:"exec-finish"`
7575
}
7676

7777
type SyncConfig struct {

sync/server_exec.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package sync
22

3+
import "fmt"
4+
35
func (server *Server) RunExec(when string) {
46
defer func() {
57
recover := recover()
@@ -19,11 +21,12 @@ func (server *Server) RunExec(when string) {
1921
}
2022

2123
func (server *Server) GetExecByWhen(when string) []Execution {
22-
var execList []Execution
23-
24-
for _, val := range server.Exec {
25-
execList = append(execList, val)
24+
switch when {
25+
case "startup":
26+
return server.ExecStartup
27+
case "finish":
28+
return server.ExecFinish
29+
default:
30+
panic(fmt.Sprintf("execution list %s is not valid", when))
2631
}
27-
28-
return execList
2932
}

0 commit comments

Comments
 (0)