-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
44 lines (34 loc) · 1.19 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
package main
import (
"encoding/json"
"fmt"
"os"
)
type config struct {
SourceDatabaseUser string `json:"sourceDatabaseUser"`
SourceDatabasePass string `json:"sourceDatabasePass"`
SourceDatabaseHost string `json:"sourceDatabaseHost"`
SourceDatabaseName string `json:"sourceDatabaseName"`
DestinationDatabaseUser string `json:"destinationDatabaseUser"`
DestinationDatabasePass string `json:"destinationDatabasePass"`
DestinationDatabaseHost string `json:"destinationDatabaseHost"`
DestinationDatabaseName string `json:"destinationDatabaseName"`
MetaDatabasePath string `json:"metaDatabasePath"`
TablesToPutLast []string `json:"tablesToPutLast"`
ExcludeTables []string `json:"excludeTables"`
InitialCopyBatchSize uint `json:"initialCopyBatchSize"`
ChangeTrackingRetentionDays uint `json:"changeTrackingRetentionDays"`
FullCopyTables []string `json:"fullcopyTables"`
}
func loadConfig(configPath string) (config, error) {
f, err := os.Open(configPath)
if err != nil {
return config{}, fmt.Errorf("open file: %w", err)
}
defer f.Close()
var ret config
if err := json.NewDecoder(f).Decode(&ret); err != nil {
return config{}, fmt.Errorf("parse file: %w", err)
}
return ret, nil
}