mirror of https://github.com/status-im/consul.git
Cleanup agent config
This commit is contained in:
parent
42c4265901
commit
d34ba3e823
|
@ -290,11 +290,9 @@ func Create(config *Config, logOutput io.Writer, logWriter *logger.LogWriter,
|
|||
// consulConfig is used to return a consul configuration
|
||||
func (a *Agent) consulConfig() *consul.Config {
|
||||
// Start with the provided config or default config
|
||||
var base *consul.Config
|
||||
base := consul.DefaultConfig()
|
||||
if a.config.ConsulConfig != nil {
|
||||
base = a.config.ConsulConfig
|
||||
} else {
|
||||
base = consul.DefaultConfig()
|
||||
}
|
||||
|
||||
// This is set when the agent starts up
|
||||
|
@ -346,10 +344,9 @@ func (a *Agent) consulConfig() *consul.Config {
|
|||
}
|
||||
if a.config.AdvertiseAddr != "" {
|
||||
base.SerfLANConfig.MemberlistConfig.AdvertiseAddr = a.config.AdvertiseAddr
|
||||
base.SerfWANConfig.MemberlistConfig.AdvertiseAddr = a.config.AdvertiseAddr
|
||||
if a.config.AdvertiseAddrWan != "" {
|
||||
base.SerfWANConfig.MemberlistConfig.AdvertiseAddr = a.config.AdvertiseAddrWan
|
||||
} else {
|
||||
base.SerfWANConfig.MemberlistConfig.AdvertiseAddr = a.config.AdvertiseAddr
|
||||
}
|
||||
base.RPCAdvertise = &net.TCPAddr{
|
||||
IP: net.ParseIP(a.config.AdvertiseAddr),
|
||||
|
@ -445,8 +442,7 @@ func (a *Agent) consulConfig() *consul.Config {
|
|||
if len(revision) > 8 {
|
||||
revision = revision[:8]
|
||||
}
|
||||
base.Build = fmt.Sprintf("%s%s:%s",
|
||||
a.config.Version, a.config.VersionPrerelease, revision)
|
||||
base.Build = fmt.Sprintf("%s%s:%s", a.config.Version, a.config.VersionPrerelease, revision)
|
||||
|
||||
// Copy the TLS configuration
|
||||
base.VerifyIncoming = a.config.VerifyIncoming || a.config.VerifyIncomingRPC
|
||||
|
|
|
@ -924,24 +924,23 @@ func (c *Config) ClientListener(override string, port int) (net.Addr, error) {
|
|||
func (c *Config) GetTokenForAgent() string {
|
||||
if c.ACLAgentToken != "" {
|
||||
return c.ACLAgentToken
|
||||
} else if c.ACLToken != "" {
|
||||
return c.ACLToken
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
if c.ACLToken != "" {
|
||||
return c.ACLToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// DecodeConfig reads the configuration from the given reader in JSON
|
||||
// format and decodes it into a proper Config structure.
|
||||
func DecodeConfig(r io.Reader) (*Config, error) {
|
||||
var raw interface{}
|
||||
var result Config
|
||||
dec := json.NewDecoder(r)
|
||||
if err := dec.Decode(&raw); err != nil {
|
||||
if err := json.NewDecoder(r).Decode(&raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check the result type
|
||||
var result Config
|
||||
if obj, ok := raw.(map[string]interface{}); ok {
|
||||
// Check for a "services", "service" or "check" key, meaning
|
||||
// this is actually a definition entry
|
||||
|
|
Loading…
Reference in New Issue