Skip to content

Commit

Permalink
Handle default values for InfluxDB Service Configs (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert authored and Nathaniel Cook committed Jun 2, 2016
1 parent 8ab770d commit 6379768
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/kapacitord/run/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func (c *Config) PostInit() {
} else if len(c.InfluxDB) == 1 && c.InfluxDB[0].Name == "" {
c.InfluxDB[0].Name = "default"
}
// Set default Values
for i, influx := range c.InfluxDB {
influx.SetDefaultValues()
c.InfluxDB[i] = influx
}
}

// NewDemoConfig returns the config that runs when no config is specified.
Expand Down
12 changes: 12 additions & 0 deletions services/influxdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ func NewConfig() Config {
}
}

func (c *Config) SetDefaultValues() {
if c.UDPBuffer == 0 {
c.UDPBuffer = udp.DefaultBuffer
}
if c.StartUpTimeout == toml.Duration(0) {
c.StartUpTimeout = toml.Duration(DefaultStartUpTimeout)
}
if c.SubscriptionProtocol == "" {
c.SubscriptionProtocol = DefaultSubscriptionProtocol
}
}

func (c Config) Validate() error {
if c.Name == "" {
return errors.New("influxdb cluster must be given a name")
Expand Down

0 comments on commit 6379768

Please sign in to comment.