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

Update envconfig defaults processing #88

Merged
merged 1 commit into from
Jul 15, 2022
Merged

Conversation

sethvargo
Copy link
Contributor

This updates to the latest version of envconfig which correctly handles not overwriting default values on input structs. This simplifies a lot of the SetDefault() logic that existed to get around this limitation.

As part of this change, I noticed there was inconsistent enforcement of the "Version" field in structs, and that the field was limited to integer values (which would prefer us from having a "v1" or "1.0-beta" version in the future). I created a small type that lets us define and manage allowed versions, and standardized on the error messages across packages. I also updated many of the error messages to be more specific about the failure.

Finally, I removed the envconfig annotations from CLIConfig, since they were actually unused; Viper handles the environment variables and initialization for this structure. For the other configs, I added dedicated tests for defaults.

@sethvargo sethvargo requested review from a team, myurtoglu and capri-xiyue July 14, 2022 22:44
@sethvargo sethvargo enabled auto-merge (squash) July 14, 2022 22:44
@sethvargo sethvargo requested review from raserva and yolocs July 14, 2022 22:44

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This updates to the latest version of envconfig which correctly handles not overwriting default values on input structs. This simplifies a lot of the SetDefault() logic that existed to get around this limitation.

As part of this change, I noticed there was inconsistent enforcement of the "Version" field in structs, and that the field was limited to integer values (which would prefer us from having a "v1" or "1.0-beta" version in the future). I created a small type that lets us define and manage allowed versions, and standardized on the error messages across packages. I also updated many of the error messages to be more specific about the failure.

Finally, I removed the envconfig annotations from CLIConfig, since they were actually unused; Viper handles the environment variables and initialization for this structure. For the other configs, I added dedicated tests for defaults.
@sethvargo sethvargo force-pushed the sethvargo/envconfig branch from 1331e17 to b71d051 Compare July 14, 2022 22:48
@sethvargo sethvargo merged commit dc9c6fa into main Jul 15, 2022
@sethvargo sethvargo deleted the sethvargo/envconfig branch July 15, 2022 13:34
sqin2019 pushed a commit that referenced this pull request Apr 6, 2023

Unverified

This user has not yet uploaded their public signing key.
This updates to the latest version of envconfig which correctly handles not overwriting default values on input structs. This simplifies a lot of the SetDefault() logic that existed to get around this limitation.

As part of this change, I noticed there was inconsistent enforcement of the "Version" field in structs, and that the field was limited to integer values (which would prefer us from having a "v1" or "1.0-beta" version in the future). I created a small type that lets us define and manage allowed versions, and standardized on the error messages across packages. I also updated many of the error messages to be more specific about the failure.

Finally, I removed the envconfig annotations from CLIConfig, since they were actually unused; Viper handles the environment variables and initialization for this structure. For the other configs, I added dedicated tests for defaults.
verbanicm pushed a commit that referenced this pull request Jun 14, 2023

Unverified

This user has not yet uploaded their public signing key.
This updates to the latest version of envconfig which correctly handles not overwriting default values on input structs. This simplifies a lot of the SetDefault() logic that existed to get around this limitation.

As part of this change, I noticed there was inconsistent enforcement of the "Version" field in structs, and that the field was limited to integer values (which would prefer us from having a "v1" or "1.0-beta" version in the future). I created a small type that lets us define and manage allowed versions, and standardized on the error messages across packages. I also updated many of the error messages to be more specific about the failure.

Finally, I removed the envconfig annotations from CLIConfig, since they were actually unused; Viper handles the environment variables and initialization for this structure. For the other configs, I added dedicated tests for defaults.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants