diff --git a/cmd/kapacitord/run/command.go b/cmd/kapacitord/run/command.go index 8644c4d1fc..b50a7bec11 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 3205ed251f..bfe102e458 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 e84f37d2f5..30ac2f1327 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 0000000000..0b57e8b872 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 9fe8bcb1aa..d90ff7047a 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/smtp/config.go b/services/smtp/config.go index 64a4b64a69..768978e5aa 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 862ddc102f..8d891c3ad6 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 39f5f7b2bb..93d7333b0c 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 ccf0a00f79..3824dd7ef3 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 a15bb3d314..f6dc115ee9 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"