forked from mandiant/gocrack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
55 lines (45 loc) · 1.48 KB
/
config.go
File metadata and controls
55 lines (45 loc) · 1.48 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
package server
import (
"errors"
"github.com/fireeye/gocrack/server/authentication"
"github.com/fireeye/gocrack/server/filemanager"
"github.com/fireeye/gocrack/server/notifications"
"github.com/fireeye/gocrack/server/rpc"
"github.com/fireeye/gocrack/server/storage"
"github.com/fireeye/gocrack/server/web"
)
// Config describes all the configuration values of the GoCrack server
type Config struct {
// Debug, if true will enable verbose logging and will overwrite the flag passed into the server
Debug bool `yaml:"debug"`
WebServer web.Config `yaml:"web_server"`
RPC rpc.Config `yaml:"rpc_server"`
Database storage.Config `yaml:"database"`
FileManager filemanager.Config `yaml:"file_manager"`
Authentication authentication.AuthSettings `yaml:"authentication"`
Notification notifications.Config `yaml:"notifications"`
}
func (s *Config) validate() error {
if err := s.WebServer.Validate(); err != nil {
return err
}
if err := s.FileManager.Validate(); err != nil {
return err
}
if err := s.RPC.Validate(); err != nil {
return err
}
if err := s.Database.Validate(); err != nil {
return err
}
if s.Database.ConnectionString == "" {
return errors.New("database.connection_string must not be empty")
}
if err := s.Authentication.Validate(); err != nil {
return err
}
if err := s.Notification.Validate(); err != nil {
return err
}
return nil
}