-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconfig.go
155 lines (134 loc) · 4.16 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package sync
import (
"regexp"
"sync"
)
var waitGroup sync.WaitGroup
type SyncConfig struct {
// Sync (remote -> local) configurations
Sync map[string]Server `yaml:"sync"`
// Deploy (local -> remote) configurations
Deploy map[string]Server `yaml:"deploy"`
}
type Server struct {
// General working path (for filesystem syncs)
Path string `yaml:"path"`
// General connection (default for all remote connections)
Connection *YamlCommandBuilderConnection `yaml:"connection"`
// Filesystem sync list
Filesystem []Filesystem `yaml:"filesystem"`
// Database sync list
Database []Database `yaml:"database"`
// Startup execution list (executed before sync)
ExecStartup []Execution `yaml:"exec-startup"`
// Finish execution list (executed after sync)
ExecFinish []Execution `yaml:"exec-finish"`
// Runtime configuration (not part of configuration)
runConfiguration *RunConfiguration
}
type Filesystem struct {
// Remove path
Path string `yaml:"path"`
// Local path (optional)
Local string `yaml:"local"`
// Filter
Filter Filter `yaml:"filter"`
// Connection for filesystem sync (optional, default is Server connection)
Connection *YamlCommandBuilderConnection `yaml:"connection"`
Options FilesystemOptions `yaml:"options"`
}
type Database struct {
// Type of database (either mysql or postgres)
Type string `yaml:"type"`
// Database name on remote database server
Db string `yaml:"database"`
// Hostname of remote database server
Hostname string `yaml:"hostname"`
// Port of remote database server
Port string `yaml:"port"`
// Username of remote database server
User string `yaml:"user"`
// Password of remote database server
Password string `yaml:"password"`
// Table filter
Filter Filter `yaml:"filter"`
// Connection for database sync (optional, default is Server connection)
Connection *YamlCommandBuilderConnection `yaml:"connection"`
// Database options
Options DatabaseOptions `yaml:"options"`
Local struct {
// Database name on local database server
Db string `yaml:"database"`
// Hostname of local database server
Hostname string `yaml:"hostname"`
// Port of local database server
Port string `yaml:"port"`
// Username of local database server
User string `yaml:"user"`
// Password of local database server
Password string `yaml:"password"`
// Connection for database sync (optional, default is empty)
Connection *YamlCommandBuilderConnection `yaml:"connection"`
// Database options
Options DatabaseOptions `yaml:"options"`
} `yaml:"local"`
// local cache for remote table list
cacheRemoteTableList []string
// local cache for local table list
cacheLocalTableList []string
}
type Execution struct {
// Type of execution (remote or local)
Type string `yaml:"type"`
// Command as string or as elements
Command YamlStringArray `yaml:"command"`
// Workdir for execution
Workdir string `yaml:"workdir"`
// Environment variables
Environment []EnvironmentVar `yaml:"environment"`
// Execution options
Options struct {
} `yaml:"options"`
}
type Filter struct {
// Exclude as strings (regexp)
Exclude []string `yaml:"exclude"`
// compiled regexp excludes
excludeRegexp []*regexp.Regexp
// Includes as strings (regexp)
Include []string `yaml:"include"`
// compiled regexp includes
includeRegexp []*regexp.Regexp
}
type DatabaseOptions struct {
// Clear database with DROP/CREATE before sync
ClearDatabase bool `yaml:"clear-database"`
// Arguments for mysqldump command
Mysqldump *YamlStringArray `yaml:"mysqldump"`
// Arguments for mysql command
Mysql *YamlStringArray `yaml:"mysql"`
// Arguments for pgdump command
Pgdump *YamlStringArray `yaml:"pgdump"`
// Arguments for psql command
Psql *YamlStringArray `yaml:"psql"`
}
type FilesystemOptions struct {
// Generate stubs (small example files) instead of fetching files from remote
GenerateStubs bool `yaml:"generate-stubs"`
// Arguments for psql command
Rsync *YamlStringArray `yaml:"rsync"`
}
type EnvironmentVar struct {
// Name of variable
Name string `yaml:"name"`
// Value of variable
Value string `yaml:"value"`
}
type RunConfiguration struct {
// Enable database sync
Database bool
// Enable filesystem sync
Filesystem bool
// Enable exec runner
Exec bool
}