Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix backward compatibility with client config #554

Merged
merged 2 commits into from
May 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions pkg/promtail/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,24 @@ func (c *Config) RegisterFlags(flags *flag.FlagSet) {
// UnmarshalYAML implement Yaml Unmarshaler
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
type raw Config
// force sane defaults.
cfg := raw{
BackoffConfig: util.BackoffConfig{
MaxBackoff: 5 * time.Second,
MaxRetries: 5,
MinBackoff: 100 * time.Millisecond,
},
BatchSize: 100 * 1024,
BatchWait: 1 * time.Second,
Timeout: 10 * time.Second,
var cfg raw
if c.URL.URL != nil {
// we used flags to set that value, which already has sane default.
cfg = raw(*c)
} else {
// force sane defaults.
cfg = raw{
BackoffConfig: util.BackoffConfig{
MaxBackoff: 5 * time.Second,
MaxRetries: 5,
MinBackoff: 100 * time.Millisecond,
},
BatchSize: 100 * 1024,
BatchWait: 1 * time.Second,
Timeout: 10 * time.Second,
}
}

if err := unmarshal(&cfg); err != nil {
return err
}
Expand Down