Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

config: added tests for various hostname acquisition strategies #472

Merged
merged 1 commit into from Sep 18, 2018

Conversation

gbbr
Copy link
Contributor

@gbbr gbbr commented Sep 18, 2018

This change ensures that configuration can only be loaded if it is valid. It adds tests for various hostname acquisition strategies to ensure hostname is always set or otherwise trace agent should fail to start.

It also renames folders test_cases to testdata, which seems more common for Go.

@gbbr gbbr added this to the next milestone Sep 18, 2018
@@ -91,17 +91,8 @@ func runAgent(ctx context.Context) {

cfg, err := config.Load(flags.ConfigPath)
if err != nil {
if !os.IsNotExist(err) {
Copy link
Contributor Author

@gbbr gbbr Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic was moved into config.Load because config should be validated when loaded, not separately using another call. This way, the config is loaded, validated, and overridden from environment in one call.

Copy link
Member

@ufoot ufoot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTM

@@ -165,11 +165,8 @@ func (c *AgentConfig) LoadYaml(path string) error {
return nil
}

// LoadEnv reads environment variable values into the config.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the fact this does not need to be public any more as Load encapsulates it all.

@gbbr gbbr merged commit ea7b315 into master Sep 18, 2018
@gbbr gbbr deleted the gbbr/config-test branch September 18, 2018 12:13
@gbbr gbbr modified the milestones: next, 6.6.0 Sep 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants