|
|
@@ -15,6 +15,14 @@ type config struct {
|
|
15
|
15
|
Secret mtglib.Secret `json:"secret"`
|
|
16
|
16
|
}
|
|
17
|
17
|
|
|
|
18
|
+func (c *config) Validate() error {
|
|
|
19
|
+ if len(c.Secret.Key) == 0 || c.Secret.Host == "" {
|
|
|
20
|
+ return fmt.Errorf("incorrect secret %s", c.Secret.String())
|
|
|
21
|
+ }
|
|
|
22
|
+
|
|
|
23
|
+ return nil
|
|
|
24
|
+}
|
|
|
25
|
+
|
|
18
|
26
|
type configRaw struct {
|
|
19
|
27
|
Debug bool `toml:"debug" json:"debug"`
|
|
20
|
28
|
Secret string `toml:"secret" json:"secret"`
|
|
|
@@ -79,5 +87,9 @@ func parseConfig(reader io.Reader) (*config, error) {
|
|
79
|
87
|
return nil, fmt.Errorf("cannot parse final config: %w", err)
|
|
80
|
88
|
}
|
|
81
|
89
|
|
|
|
90
|
+ if err := conf.Validate(); err != nil {
|
|
|
91
|
+ return nil, fmt.Errorf("cannot validate config: %w", err)
|
|
|
92
|
+ }
|
|
|
93
|
+
|
|
82
|
94
|
return conf, nil
|
|
83
|
95
|
}
|