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

Simplify common-case setup #13

Merged
merged 3 commits into from
May 20, 2020
Merged

Simplify common-case setup #13

merged 3 commits into from
May 20, 2020

Conversation

dfinkel
Copy link
Contributor

@dfinkel dfinkel commented May 14, 2020

Two changes:

  • Make optional arguments to the NewWatchingSource constructor variadic options
  • Add an ez subpackage with a wrapper for creating a flag source, file source and env source and appropriately using the blank source for picking the appropriate configuration file to read.

If the new function is considered simple enough, we can add a few more "simple" functions to the ez package. (note: this has to be its own subpackage because of circular dependencies involving the Source interface, otherwise).

ez/ez.go Outdated
}

// YAMLConfigFlagEnv takes advantage of the ConfigWithConfigPath cfg.
func YAMLConfigFlagEnv(ctx context.Context, cfg ConfigWithConfigPath, watch bool) (*dials.Dials, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we pass the decoder as a parameter here (and in fileSource) so this can be applied to all JSON, YAML, and TOML? Or should we provide another function called JSONConfigFlagEnv if we want to keep the interface simple?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can do all of the above.
The point of this subpackage is to make it easy.
Given the amount of code in this function, it's worthwhile factoring out most of it and providing a YAML wrapper, a JSON wrapper, etc.

I've rejigged this package a bit and renamed the functions to match the actual stack-order.

@dfinkel dfinkel merged commit ed03f8c into master May 20, 2020
@dfinkel dfinkel deleted the ez_file_watch branch May 20, 2020 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants