diff --git a/CHANGELOG.md b/CHANGELOG.md index 49a1a7920..d6d3866bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This way you can easily tell which versions of Telegraf, InfluxDB, Chronograf an - [#72](https://github.com/influxdata/kapacitor/issues/72): Add support for User Defined Functions (UDFs). - [#138](https://github.com/influxdata/kapacitor/issues/138): Change over to influxdata github org. - [#139](https://github.com/influxdata/kapacitor/issues/139): Alerta.io support thanks! @md14454 +- [#155](https://github.com/influxdata/kapacitor/pull/155): Standardized config across TICK stack. ### Bugfixes diff --git a/cmd/kapacitord/run/command.go b/cmd/kapacitord/run/command.go index 8644c4d1f..b50a7bec1 100644 --- a/cmd/kapacitord/run/command.go +++ b/cmd/kapacitord/run/command.go @@ -11,7 +11,7 @@ import ( "runtime" "strconv" - "github.com/BurntSushi/toml" + cfg "github.com/influxdata/config" "github.com/influxdata/kapacitor/services/logging" ) @@ -207,7 +207,7 @@ func (cmd *Command) ParseConfig(path string) (*Config, error) { log.Printf("Using configuration at: %s\n", path) config := NewConfig() - if _, err := toml.DecodeFile(path, &config); err != nil { + if err := cfg.DecodeFile(path, &config); err != nil { return nil, err } diff --git a/cmd/kapacitord/run/config_command.go b/cmd/kapacitord/run/config_command.go index 3205ed251..bfe102e45 100644 --- a/cmd/kapacitord/run/config_command.go +++ b/cmd/kapacitord/run/config_command.go @@ -6,7 +6,7 @@ import ( "io" "os" - "github.com/BurntSushi/toml" + cfg "github.com/influxdata/config" ) // PrintConfigCommand represents the command executed by "kapacitord config". @@ -57,7 +57,7 @@ func (cmd *PrintConfigCommand) Run(args ...string) error { return fmt.Errorf("%s. To generate a valid configuration file run `kapacitord config > kapacitor.generated.conf`.", err) } - toml.NewEncoder(cmd.Stdout).Encode(config) + cfg.NewEncoder(cmd.Stdout).Encode(config) fmt.Fprint(cmd.Stdout, "\n") return nil @@ -71,7 +71,7 @@ func (cmd *PrintConfigCommand) parseConfig(path string) (*Config, error) { } config := NewConfig() - if _, err := toml.DecodeFile(path, &config); err != nil { + if err := cfg.DecodeFile(path, &config); err != nil { return nil, err } return config, nil diff --git a/cmd/kapacitord/run/config_test.go b/cmd/kapacitord/run/config_test.go index e84f37d2f..30ac2f132 100644 --- a/cmd/kapacitord/run/config_test.go +++ b/cmd/kapacitord/run/config_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/BurntSushi/toml" + "github.com/influxdata/config" "github.com/influxdata/kapacitor/cmd/kapacitord/run" ) @@ -12,7 +12,7 @@ import ( func TestConfig_Parse(t *testing.T) { // Parse configuration. var c run.Config - if _, err := toml.Decode(` + if err := config.Decode(` [replay] dir = "/tmp/replay" @@ -34,7 +34,7 @@ dir = "/tmp/task" func TestConfig_Parse_EnvOverride(t *testing.T) { // Parse configuration. var c run.Config - if _, err := toml.Decode(` + if err := config.Decode(` [replay] dir = "/tmp/replay" diff --git a/cmd/kapacitord/run/run.test b/cmd/kapacitord/run/run.test new file mode 100755 index 000000000..0b57e8b87 Binary files /dev/null and b/cmd/kapacitord/run/run.test differ diff --git a/cmd/kapacitord/run/server_test.go b/cmd/kapacitord/run/server_test.go index 9fe8bcb1a..d90ff7047 100644 --- a/cmd/kapacitord/run/server_test.go +++ b/cmd/kapacitord/run/server_test.go @@ -15,13 +15,13 @@ import ( "testing" "time" + "github.com/influxdata/config" "github.com/influxdata/kapacitor" "github.com/influxdata/kapacitor/cmd/kapacitord/run" "github.com/influxdata/kapacitor/services/udf" "github.com/influxdb/influxdb/client" "github.com/influxdb/influxdb/influxql" "github.com/influxdb/influxdb/models" - "github.com/influxdb/influxdb/toml" ) func TestServer_Ping(t *testing.T) { @@ -714,7 +714,7 @@ func TestServer_UDFAgents(t *testing.T) { config: udf.FunctionConfig{ Prog: "go", Args: []string{"run", filepath.Join(udfDir, "agent/examples/moving_avg.go")}, - Timeout: toml.Duration(time.Minute), + Timeout: config.Duration(time.Minute), }, }, // Python @@ -723,7 +723,7 @@ func TestServer_UDFAgents(t *testing.T) { config: udf.FunctionConfig{ Prog: "python2", Args: []string{"-u", filepath.Join(udfDir, "agent/examples/moving_avg.py")}, - Timeout: toml.Duration(time.Minute), + Timeout: config.Duration(time.Minute), Env: map[string]string{ "PYTHONPATH": strings.Join( []string{filepath.Join(udfDir, "agent/py"), os.Getenv("PYTHONPATH")}, diff --git a/services/deadman/config.go b/services/deadman/config.go index 2cda50122..e09e915ea 100644 --- a/services/deadman/config.go +++ b/services/deadman/config.go @@ -3,12 +3,12 @@ package deadman import ( "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) const ( // Default deadman's switch interval - DefaultInterval = toml.Duration(time.Second * 10) + DefaultInterval = config.Duration(time.Second * 10) // Default deadman's switch threshold DefaultThreshold = float64(0) // Default deadman's switch id @@ -18,11 +18,11 @@ const ( ) type Config struct { - Interval toml.Duration `toml:"interval"` - Threshold float64 `toml:"threshold"` - Id string `toml:"id"` - Message string `toml:"message"` - Global bool `toml:"global"` + Interval config.Duration `toml:"interval"` + Threshold float64 `toml:"threshold"` + Id string `toml:"id"` + Message string `toml:"message"` + Global bool `toml:"global"` } func NewConfig() Config { diff --git a/services/smtp/config.go b/services/smtp/config.go index 64a4b64a6..768978e5a 100644 --- a/services/smtp/config.go +++ b/services/smtp/config.go @@ -3,7 +3,7 @@ package smtp import ( "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) type Config struct { @@ -21,7 +21,7 @@ type Config struct { // Default To addresses To []string `toml:"to"` // Close connection to SMTP server after idle timeout has elapsed - IdleTimeout toml.Duration `toml:"idle-timeout"` + IdleTimeout config.Duration `toml:"idle-timeout"` } func NewConfig() Config { @@ -30,6 +30,6 @@ func NewConfig() Config { Port: 25, Username: "", Password: "", - IdleTimeout: toml.Duration(time.Second * 30), + IdleTimeout: config.Duration(time.Second * 30), } } diff --git a/services/stats/config.go b/services/stats/config.go index 862ddc102..8d891c3ad 100644 --- a/services/stats/config.go +++ b/services/stats/config.go @@ -3,14 +3,14 @@ package stats import ( "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) type Config struct { - Enabled bool `toml:"enabled"` - StatsInterval toml.Duration `toml:"stats-interval"` - Database string `toml:"database"` - RetentionPolicy string `toml:"retention-policy"` + Enabled bool `toml:"enabled"` + StatsInterval config.Duration `toml:"stats-interval"` + Database string `toml:"database"` + RetentionPolicy string `toml:"retention-policy"` } func NewConfig() Config { @@ -18,6 +18,6 @@ func NewConfig() Config { Enabled: true, Database: "_kapacitor", RetentionPolicy: "default", - StatsInterval: toml.Duration(10 * time.Second), + StatsInterval: config.Duration(10 * time.Second), } } diff --git a/services/task_store/config.go b/services/task_store/config.go index 39f5f7b2b..93d7333b0 100644 --- a/services/task_store/config.go +++ b/services/task_store/config.go @@ -4,18 +4,18 @@ import ( "fmt" "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) type Config struct { - Dir string `toml:"dir"` - SnapshotInterval toml.Duration `toml:"snapshot-interval"` + Dir string `toml:"dir"` + SnapshotInterval config.Duration `toml:"snapshot-interval"` } func NewConfig() Config { return Config{ Dir: "./tasks", - SnapshotInterval: toml.Duration(time.Minute), + SnapshotInterval: config.Duration(time.Minute), } } diff --git a/services/udf/config.go b/services/udf/config.go index ccf0a00f7..3824dd7ef 100644 --- a/services/udf/config.go +++ b/services/udf/config.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/influxdb/influxdb/toml" + "github.com/influxdata/config" ) type Config struct { @@ -14,7 +14,7 @@ type Config struct { type FunctionConfig struct { Prog string `toml:"prog"` Args []string `toml:"args"` - Timeout toml.Duration `toml:"timeout"` + Timeout config.Duration `toml:"timeout"` Env map[string]string `toml:"env"` } diff --git a/services/udp/config_test.go b/services/udp/config_test.go index a15bb3d31..f6dc115ee 100644 --- a/services/udp/config_test.go +++ b/services/udp/config_test.go @@ -3,14 +3,14 @@ package udp_test import ( "testing" - "github.com/BurntSushi/toml" + "github.com/influxdata/config" "github.com/influxdb/influxdb/services/udp" ) func TestConfig_Parse(t *testing.T) { // Parse configuration. var c udp.Config - if _, err := toml.Decode(` + if err := config.Decode(` enabled = true bind-address = ":4444" database = "awesomedb" diff --git a/udf/agent/examples/moving_avg.py b/udf/agent/examples/moving_avg.py index c76311091..2e4a3331e 100644 --- a/udf/agent/examples/moving_avg.py +++ b/udf/agent/examples/moving_avg.py @@ -1,4 +1,3 @@ - import sys import json from agent import Agent, Handler @@ -68,7 +67,6 @@ def info(self): response.info.options['size'].valueTypes.append(udf_pb2.INT) response.info.options['as'].valueTypes.append(udf_pb2.STRING) - logger.info("info") return response def init(self, init_req):