-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconfig.go
73 lines (59 loc) · 1.66 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package config
import (
"github.com/hashicorp/logutils"
"github.com/luizbafilho/fusis/net"
)
var (
LOG_LEVELS = []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}
)
type BalancerConfig struct {
Interfaces
Name string `mapstructure:"name" validate:"required"`
LogLevel string `mapstructure:"log-level"`
ClusterMode string `mapstructure:"cluster-mode"` //Defines if balancer is in UNICAST or ANYCAST
EnableHealthChecks bool `mapstructure:"enable-health-checks"`
StorePrefix string `mapstructure:"store-prefix"`
Bgp
Ipam
Metrics
// StoreAddress string `mapstructure:"store-address"`
EtcdEndpoints string `mapstructure:"etcd-endpoints"`
}
type AgentConfig struct {
Interface string
Balancer string
Name string
Address string
Port uint16
Weight int32
Mode string
Service string
}
type Interfaces struct {
Inbound string `validate:"required"`
Outbound string `validate:"required"`
}
type Bgp struct {
As uint32 `validate:"required"`
RouterId string `validate:"ipv4,required" mapstructure:"router-id"`
Neighbors []Neighbor `validate:"required,dive"`
}
type Neighbor struct {
Address string `validate:"ipv4,required"`
PeerAs uint32 `validate:"required" mapstructure:"peer-as"`
}
type Ipam struct {
Ranges []string `validate:"dive,cidrv4"`
}
type Metrics struct {
Publisher string
Interval uint16
Params map[string]interface{}
Extras map[string]string
}
func (c *BalancerConfig) GetIpByInterface() (string, error) {
return net.GetIpByInterface(c.Interfaces.Inbound)
}
func (c *AgentConfig) GetIpByInterface() (string, error) {
return net.GetIpByInterface(c.Interface)
}