-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
50 lines (43 loc) · 1.17 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
package main
import ini "gopkg.in/ini.v1"
// LoadConfig loads is a wrapper around ini.MapTo function, which enables mysql type bools.
func LoadConfig(path string) (*Configuration, error) {
cfg, err := ini.LoadSources(ini.LoadOptions{AllowBooleanKeys: true}, path)
cfg.NameMapper = ini.TitleUnderscore
Config := new(Configuration)
err = cfg.MapTo(Config)
return Config, err
}
// Configuration is the struct in which all the configuration is loaded.
type Configuration struct {
LogFileLocation string
DataFileLocation string
MaxWorkerThreads int
Source string
Destination string
Saveguard
Scantype
Copy
OnStartScript
}
// OnStartScript executes a file before the backup process starts.
type OnStartScript struct {
OnStartScriptEnable bool
OnStartScriptPath string
OnStartScriptArgs string
}
// Copy is an Configuration struct extension
type Copy struct {
UseExternalCopy bool
ExternalCopyPath string
}
// Scantype is an Configuration struct extension
type Scantype struct {
Blake2bBased bool
TimestampBased bool
}
// Saveguard is an Configuration struct extension
type Saveguard struct {
SaveguardMaxPercentage int
SaveguardEnable bool
}