Skip to content

Commit

Permalink
Support env overrides for all inputs of the same type
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnaraasen committed Apr 13, 2016
1 parent 36ca49c commit 41d4522
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [#6237](https://github.com/influxdata/influxdb/issues/6237): Enable continuous integration testing on Windows platform via AppVeyor. Thanks @mvadu
- [#6263](https://github.com/influxdata/influxdb/pull/6263): Reduce UDP Service allocation size.
- [#6228](https://github.com/influxdata/influxdb/pull/6228): Support for multiple listeners for collectd and OpenTSDB inputs.
- [#6334](https://github.com/influxdata/influxdb/pull/6334): Allow environment variables to be set per input type.

### Bugfixes

Expand Down
3 changes: 3 additions & 0 deletions cmd/influxd/run/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ func (c *Config) applyEnvOverrides(prefix string, spec reflect.Value) error {
// e.g. GRAPHITE_0
if f.Kind() == reflect.Slice || f.Kind() == reflect.Array {
for i := 0; i < f.Len(); i++ {
if err := c.applyEnvOverrides(key, f.Index(i)); err != nil {
return err
}
if err := c.applyEnvOverrides(fmt.Sprintf("%s_%d", key, i), f.Index(i)); err != nil {
return err
}
Expand Down
12 changes: 11 additions & 1 deletion cmd/influxd/run/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ bind-address = ":2010"
[[udp]]
bind-address = ":4444"
[[udp]]
[monitoring]
enabled = true
Expand All @@ -154,6 +156,10 @@ enabled = true
t.Fatalf("failed to set env var: %v", err)
}

if err := os.Setenv("INFLUXDB_UDP_0_BIND_ADDRESS", ":5555"); err != nil {
t.Fatalf("failed to set env var: %v", err)
}

if err := os.Setenv("INFLUXDB_GRAPHITE_1_PROTOCOL", "udp"); err != nil {
t.Fatalf("failed to set env var: %v", err)
}
Expand All @@ -170,10 +176,14 @@ enabled = true
t.Fatalf("failed to apply env overrides: %v", err)
}

if c.UDPInputs[0].BindAddress != ":4444" {
if c.UDPInputs[0].BindAddress != ":5555" {
t.Fatalf("unexpected udp bind address: %s", c.UDPInputs[0].BindAddress)
}

if c.UDPInputs[1].BindAddress != ":1234" {
t.Fatalf("unexpected udp bind address: %s", c.UDPInputs[1].BindAddress)
}

if c.GraphiteInputs[1].Protocol != "udp" {
t.Fatalf("unexpected graphite protocol: %s", c.GraphiteInputs[1].Protocol)
}
Expand Down

0 comments on commit 41d4522

Please sign in to comment.