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 default values applied to Config #556

Merged
merged 1 commit into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/grafana/agent/pkg/loki"
"github.com/grafana/agent/pkg/prom"
"github.com/grafana/agent/pkg/tempo"
"github.com/grafana/agent/pkg/util"
"github.com/pkg/errors"
"github.com/prometheus/common/version"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -42,7 +43,11 @@ type Config struct {

// UnmarshalYAML implements yaml.Unmarshaler.
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
// Apply defaults to the config from our struct and any defaults inherited
// from flags.
*c = DefaultConfig
util.DefaultConfigFromFlags(c)

type config Config
return unmarshal((*config)(c))
}
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ prometheus:
require.NotEmpty(t, c.Prometheus.ServiceConfig.Lifecycler.InfNames)
require.NotZero(t, c.Prometheus.ServiceConfig.Lifecycler.NumTokens)
require.NotZero(t, c.Prometheus.ServiceConfig.Lifecycler.HeartbeatPeriod)
require.True(t, c.Server.RegisterInstrumentation)
}

func TestConfig_OverrideDefaultsOnLoad(t *testing.T) {
Expand Down