-
Notifications
You must be signed in to change notification settings - Fork 95
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: validation integration, part 1 #700
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TylerHelmuth
approved these changes
Jun 5, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@echo | ||
@echo "+++ validating sample config" | ||
@echo | ||
go run . validate --input=minimal_config.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
go run . validate --input=minimal_config.yaml | |
go run . validate --input=minimal_config.yaml | |
kentquirk
added a commit
that referenced
this pull request
Jun 6, 2023
…#701) Note: this PR is dependent on #700 -- that one should be merged first. ## Which problem is this PR solving? - Adds complete rules validation to the validation system, plus a few bonus features. ## Short description of the changes - Add a rulesMeta.yaml file to describe the rules data. - Extend the validation system to handle a structure nested more deeply than the basic config validation, which was only 2 layers deep. This meant adding objects and arrays of objects. - Add a few more validation features to support the new semantics. - Add a "did you mean...?" feature to suggest the proper spelling if someone gets something wrong. This is particularly useful when you get the case wrong. - Generate a .md file from the rules metadata; it's not yet pretty but it's a good start. Will improve before release. It's been validated against the converted rules_complete rules file. ## Example results: Rule snippet ``` dataset4: RuleBasedSampler: Rules: ``` Validation: ``` Validation Errors in rules file: Within sampler dataset4: unknown group RuleBasedSampler; did you mean RulesBasedSampler? ``` Rule snippet ``` Samplers: dataset1: DynamicSampler: ClearFrequency: 1 SamplerRate: 10 FieldList: - 10 - request.method - http.target - response.status_code UseTraceLength: "true" ``` Validation: ``` Validation Errors in rules file: Within sampler dataset1: field DynamicSampler.UseTraceLength must be a bool Within sampler dataset1: field DynamicSampler.ClearFrequency (1) must be a valid duration like '3m30s' or '100ms' Within sampler dataset1: unknown field DynamicSampler.SamplerRate; did you mean SampleRate? Within sampler dataset1: field DynamicSampler.FieldList must be a string array but contains non-string 10 Within sampler dataset1: the group DynamicSampler is missing its required field SampleRate ``` I'm really happy with this -- it makes it almost impossible to make a major error in your rules. Next up: run the validators on Refinery startup. Closes #566 Closes #559 Closes #518 Closes #273 Closes #266
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
This fleshes out the validation config file and makes it really work.
The validation system needed to be part of Refinery itself; I tried putting it in its own library, but it made more sense to make it an integral part of config.
Short description of the changes
This does not do rule validation yet -- that's next.
This also does not integrate the validation into Refinery's loading yet, although that is just a few lines of code. That will come after rule validation.