File tree Expand file tree Collapse file tree 7 files changed +126
-13
lines changed Expand file tree Collapse file tree 7 files changed +126
-13
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
- import "fmt"
3
+ import (
4
+ "fmt"
5
+ "./sync"
6
+ )
4
7
5
8
type DeployCommand struct {
6
9
AbstractCommand
7
10
Positional struct {
8
11
Server string `description:"server configuration key"`
9
12
} `positional-args:"true"`
10
- Dump bool `long:"dump" description:"dump configuration as yaml"`
13
+ Dump bool `long:"dump" description:"dump configuration as yaml"`
14
+ OnlyFilesystem bool `long:"filesystem" description:"deploy only filesystem"`
15
+ OnlyDatabase bool `long:"database" description:"deploy only database"`
16
+ SkipExec bool `long:"skip-exec" description:"skip execution"`
11
17
}
12
18
13
19
// Run deployment command
@@ -21,6 +27,8 @@ func (command *DeployCommand) Execute(args []string) error {
21
27
Logger .Step ("using Server[%s]" , server )
22
28
Logger .Step ("using %s" , confServer .Connection .GetInstance ().String ())
23
29
30
+ confServer .SetRunConfiguration (command .buildSyncRunConfig ())
31
+
24
32
// --dump
25
33
if command .Dump {
26
34
fmt .Println ()
@@ -32,3 +40,26 @@ func (command *DeployCommand) Execute(args []string) error {
32
40
33
41
return nil
34
42
}
43
+
44
+ func (command * DeployCommand ) buildSyncRunConfig () (conf sync.RunConfiguration ) {
45
+ // Init
46
+ conf .Exec = true
47
+ conf .Database = true
48
+ conf .Filesystem = true
49
+
50
+ if command .OnlyFilesystem {
51
+ conf .Database = false
52
+ conf .Filesystem = true
53
+ }
54
+
55
+ if command .OnlyDatabase {
56
+ conf .Database = true
57
+ conf .Filesystem = false
58
+ }
59
+
60
+ if command .SkipExec {
61
+ conf .Exec = false
62
+ }
63
+
64
+ return
65
+ }
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
- import "fmt"
3
+ import (
4
+ "fmt"
5
+ "./sync"
6
+ )
4
7
5
8
type SyncCommand struct {
6
9
AbstractCommand
7
10
Positional struct {
8
11
Server string `description:"server configuration key"`
9
12
} `positional-args:"true"`
10
- Dump bool `long:"dump" description:"dump configuration as yaml"`
13
+ Dump bool `long:"dump" description:"dump configuration as yaml"`
14
+ OnlyFilesystem bool `long:"filesystem" description:"sync only filesystem"`
15
+ OnlyDatabase bool `long:"database" description:"sync only database"`
16
+ SkipExec bool `long:"skip-exec" description:"skip execution"`
11
17
}
12
18
13
19
// Run sync command
@@ -21,6 +27,8 @@ func (command *SyncCommand) Execute(args []string) error {
21
27
Logger .Step ("using Server[%s]" , server )
22
28
Logger .Step ("using %s" , confServer .Connection .GetInstance ().String ())
23
29
30
+ confServer .SetRunConfiguration (command .buildSyncRunConfig ())
31
+
24
32
// --dump
25
33
if command .Dump {
26
34
fmt .Println ()
@@ -32,3 +40,26 @@ func (command *SyncCommand) Execute(args []string) error {
32
40
33
41
return nil
34
42
}
43
+
44
+ func (command * SyncCommand ) buildSyncRunConfig () (conf sync.RunConfiguration ) {
45
+ // Init
46
+ conf .Exec = true
47
+ conf .Database = true
48
+ conf .Filesystem = true
49
+
50
+ if command .OnlyFilesystem {
51
+ conf .Database = false
52
+ conf .Filesystem = true
53
+ }
54
+
55
+ if command .OnlyDatabase {
56
+ conf .Database = true
57
+ conf .Filesystem = false
58
+ }
59
+
60
+ if command .SkipExec {
61
+ conf .Exec = false
62
+ }
63
+
64
+ return
65
+ }
Original file line number Diff line number Diff line change @@ -82,9 +82,17 @@ type Server struct {
82
82
Database []Database `yaml:"database"`
83
83
ExecStartup []Execution `yaml:"exec-startup"`
84
84
ExecFinish []Execution `yaml:"exec-finish"`
85
+
86
+ runConfiguration * RunConfiguration
85
87
}
86
88
87
89
type SyncConfig struct {
88
90
Sync map [string ]Server `yaml:"sync"`
89
91
Deploy map [string ]Server `yaml:"deploy"`
90
92
}
93
+
94
+ type RunConfiguration struct {
95
+ Database bool
96
+ Filesystem bool
97
+ Exec bool
98
+ }
Original file line number Diff line number Diff line change 1
1
package sync
2
2
3
- import "gopkg.in/yaml.v2"
3
+ import (
4
+ "gopkg.in/yaml.v2"
5
+ )
6
+
7
+ func (server * Server ) Init () {
8
+ if server .runConfiguration == nil {
9
+ server .runConfiguration = & RunConfiguration {
10
+ Database : true ,
11
+ Filesystem : true ,
12
+ }
13
+ }
14
+ }
4
15
5
16
func (server * Server ) GetLocalPath () string {
6
17
if server .Path == "" {
@@ -10,6 +21,10 @@ func (server *Server) GetLocalPath() string {
10
21
return server .Path
11
22
}
12
23
24
+ func (server * Server ) SetRunConfiguration (conf RunConfiguration ) {
25
+ server .runConfiguration = & conf
26
+ }
27
+
13
28
func (server * Server ) AsYaml () string {
14
29
conf , _ := yaml .Marshal (server )
15
30
return string (conf )
Original file line number Diff line number Diff line change @@ -6,10 +6,23 @@ func (server *Server) Deploy() {
6
6
ShellErrorHandler (recover )
7
7
}()
8
8
9
- server .RunExec ("startup" )
10
- server .DeployFilesystem ()
11
- server .DeployDatabases ()
12
- server .RunExec ("finish" )
9
+ server .Init ()
10
+
11
+ if server .runConfiguration .Exec {
12
+ server .RunExec ("startup" )
13
+ }
14
+
15
+ if server .runConfiguration .Filesystem {
16
+ server .DeployFilesystem ()
17
+ }
18
+
19
+ if server .runConfiguration .Database {
20
+ server .DeployDatabases ()
21
+ }
22
+
23
+ if server .runConfiguration .Exec {
24
+ server .RunExec ("finish" )
25
+ }
13
26
14
27
waitGroup .Wait ()
15
28
}
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ func (server *Server) RunExec(when string) {
8
8
ShellErrorHandler (recover )
9
9
}()
10
10
11
+ server .Init ()
12
+
11
13
execList := server .GetExecByWhen (when )
12
14
13
15
if len (execList ) >= 1 {
Original file line number Diff line number Diff line change @@ -6,10 +6,23 @@ func (server *Server) Sync() {
6
6
ShellErrorHandler (recover )
7
7
}()
8
8
9
- server .RunExec ("startup" )
10
- server .SyncFilesystem ()
11
- server .SyncDatabases ()
12
- server .RunExec ("finish" )
9
+ server .Init ()
10
+
11
+ if server .runConfiguration .Exec {
12
+ server .RunExec ("startup" )
13
+ }
14
+
15
+ if server .runConfiguration .Filesystem {
16
+ server .SyncFilesystem ()
17
+ }
18
+
19
+ if server .runConfiguration .Database {
20
+ server .SyncDatabases ()
21
+ }
22
+
23
+ if server .runConfiguration .Exec {
24
+ server .RunExec ("finish" )
25
+ }
13
26
14
27
waitGroup .Wait ()
15
28
}
You can’t perform that action at this time.
0 commit comments