-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
66 lines (58 loc) · 1.67 KB
/
Copy pathconfig.go
File metadata and controls
66 lines (58 loc) · 1.67 KB
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
// Package main provides the bucket synchronisation service.
package main
import (
"os"
"path/filepath"
"sync"
"gopkg.in/yaml.v3"
)
var config Config
var configMutex sync.RWMutex
type Remote struct {
Name string `yaml:"name"`
Endpoint string `yaml:"endpoint"`
AccessKey string `yaml:"accessKey"`
SecretKey string `yaml:"secretKey"`
}
type Inbound struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Source string `yaml:"source"`
Exchange string `yaml:"exchange"`
Queue string `yaml:"queue"`
Remote string `yaml:"remote"`
Destination string `yaml:"destination"`
}
type Outbound struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Sensitive bool `yaml:"sensitive"`
Source string `yaml:"source"`
Destination string `yaml:"destination"`
IgnorePatterns []string `yaml:"ignore_patterns,omitempty"`
ProcessWith string `yaml:"process_with,omitempty"`
}
type Config struct {
LogLevel string `yaml:"log_level"`
LogJSON bool `yaml:"log_json"`
EnableNotifications bool `yaml:"enable_notifications"`
Outbound []Outbound `yaml:"outbound"`
Inbound []Inbound `yaml:"inbound"`
Remotes []Remote `yaml:"remotes"`
}
func readConfig(filename string) error {
// Read YAML config file
fullpath, _ := filepath.Abs(filename)
// #nosec G304 - This is intentional file reading based on user input
yamlFile, err := os.ReadFile(fullpath)
if err != nil {
return err
}
configMutex.Lock()
err = yaml.Unmarshal(yamlFile, &config)
configMutex.Unlock()
if err != nil {
return err
}
return nil
}