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

config: added tests for various hostname acquisition strategies#472

Merged
gbbr merged 1 commit into
masterfrom
gbbr/config-test
Sep 18, 2018
Merged

config: added tests for various hostname acquisition strategies#472
gbbr merged 1 commit into
masterfrom
gbbr/config-test

Conversation

@gbbr

@gbbr gbbr commented Sep 18, 2018

Copy link
Copy Markdown
Contributor

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
Comment thread cmd/trace-agent/main.go

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

@gbbr gbbr Sep 18, 2018

Copy link
Copy Markdown
Contributor Author

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.

@ufoot ufoot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

GTM

Comment thread config/agent.go
return nil
}

// LoadEnv reads environment variable values into the config.

Copy link
Copy Markdown

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.

3 participants