/
config.go
45 lines (36 loc) · 980 Bytes
/
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
package minion
import (
"fmt"
"github.com/cloudhut/kminion/v2/e2e"
)
type Config struct {
ConsumerGroups ConsumerGroupConfig `koanf:"consumerGroups"`
Topics TopicConfig `koanf:"topics"`
LogDirs LogDirsConfig `koanf:"logDirs"`
EndToEnd e2e.Config `koanf:"endToEnd"`
}
func (c *Config) SetDefaults() {
c.ConsumerGroups.SetDefaults()
c.Topics.SetDefaults()
c.LogDirs.SetDefaults()
c.EndToEnd.SetDefaults()
}
func (c *Config) Validate() error {
err := c.ConsumerGroups.Validate()
if err != nil {
return fmt.Errorf("failed to consumer group config: %w", err)
}
err = c.Topics.Validate()
if err != nil {
return fmt.Errorf("failed to validate topic config: %w", err)
}
err = c.LogDirs.Validate()
if err != nil {
return fmt.Errorf("failed to validate log dirs config: %w", err)
}
err = c.EndToEnd.Validate()
if err != nil {
return fmt.Errorf("failed to validate endToEnd config: %w", err)
}
return nil
}