-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[jaeger-v2] Standard way to validate configuration #6185
Comments
@yurishkuro It looks like our govalidator should this pick up. See the following tests: No Error func TestValidate(t *testing.T) {
type TestConfiguration struct {
Servers []string `mapstructure:"server_urls" valid:"required,url"`
}
config := TestConfiguration{
Servers: []string{"localhost:8000/dummyserver"},
}
_, err := govalidator.ValidateStruct(config)
require.NoError(t, err)
} Misspelling Error func TestValidate(t *testing.T) {
type TestConfiguration struct {
Servers []string `mapstructure:"server_urls" valid:"notatag,url"`
}
config := TestConfiguration{
Servers: []string{"localhost:8000/dummyserver"},
}
require.NoError(t, err)
} This test fails with
|
Are we instead looking to validate tags like |
Yes, the issue is about ensuring that the annotations are correct. It's possible that this comes out of the box when we invoke the corresponding utility - it would parse tags and hopefully complain about invalid syntax. But what if it doesn't? |
@yurishkuro Based on the unit tests above, it looks like anything defined under the |
in the PR where the comment was from the tag was I think at minimum we should have a unit test that checks that an invalid config values are properly reported by the validation function. Not the various permutations of fields, just the fact that the validation is seeing the right tags |
Ah yes - in that case nothing was reported by the govalidator because it only validates when the
This will cause the validator to fail if the |
sounds good, although please double check that it's not actually making the struct fields themselves required in the configuration |
@yurishkuro Tried this out and unfortunately this won't work because we have some OTEL components embedded which do not have the valid tag so the validation will always fail. The govalidator should catch syntax errors for anything defined under valid. For example, the following would fail because
However, if our goal is to catch when we misspell the tag itself ( |
We can probably we can probably close this and wait for schema-first configs to be available, at which point the tags would be automatically generated. |
Related to this thread: #5152 (comment)
For example, a field may have an annotation like this:
mapstructure:"server_urls" validate:"required,min=1,dive,url"
How do we know that the syntax of those tags is valid?
The text was updated successfully, but these errors were encountered: