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

feat: add support for config struct validate tags #1015

Merged

Conversation

hspitzley-czi
Copy link
Contributor

@hspitzley-czi hspitzley-czi commented Mar 6, 2024

  • Adds validate tag support
  • Adds missing unit tests

config/config.go Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/validation.go Outdated Show resolved Hide resolved
config/validation.go Outdated Show resolved Hide resolved
config/validation.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
@hspitzley-czi hspitzley-czi marked this pull request as ready for review March 6, 2024 22:44
@hspitzley-czi hspitzley-czi requested a review from a team as a code owner March 6, 2024 22:44
@@ -170,7 +171,7 @@ func evaluateConfigWithEnv(configFile io.Reader, writers ...io.Writer) (io.Reade
return nil, fmt.Errorf("unable to read the config file: %w", err)
}

t := template.New("appConfigTemplate")
t := template.New("appConfigTemplate").Option("missingkey=zero")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is neat, previously the template was setting the value to <no value> when the env var the template needed wasn't set, now it defaults to the "zero value" for whatever type (so we actually get an empty string that can be caught by the validate:"required" tag)

@hspitzley-czi hspitzley-czi merged commit e13bc83 into main Mar 7, 2024
9 checks passed
@hspitzley-czi hspitzley-czi deleted the CCIE-2491-add-validator-tags-to-go-misc-configs-module branch March 7, 2024 15:12
@czi-github-helper czi-github-helper bot mentioned this pull request Mar 7, 2024
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.

None yet

2 participants