-
Notifications
You must be signed in to change notification settings - Fork 485
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: Validate Interval and IntervalAction before loading from config #3646
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3646 +/- ##
=======================================
Coverage 47.29% 47.29%
=======================================
Files 112 112
Lines 9174 9174
=======================================
Hits 4339 4339
Misses 4462 4462
Partials 373 373 Continue to review full report at Codecov.
|
Name: configuration.Intervals[i].Name, | ||
Start: configuration.Intervals[i].Start, | ||
End: configuration.Intervals[i].End, | ||
Interval: configuration.Intervals[i].Interval, | ||
} | ||
validateErr := common.Validate(dto) | ||
if validateErr != nil { | ||
return errors.NewCommonEdgeXWrapper(validateErr) |
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.
wrap the error with the proper error message:
validate pre-defined Interval %s from configuration failed , dto.Name
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.
Modified.
_, err := dbClient.IntervalActionByName(action.Name) | ||
validateErr := common.Validate(dto) | ||
if validateErr != nil { | ||
return errors.NewCommonEdgeXWrapper(validateErr) |
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.
wrap the error with the proper error message:
validate pre-defined IntervalAction %s from configuration failed , dto.Name
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.
Modified.
Interval and IntervalAction should be created as a DTO, and call validate() to ensure the data is valid. Close: #3642 Signed-off-by: weichou <[email protected]>
Close: #3642 Signed-off-by: weichou <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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
Close: #3642
PR Checklist
Please check if your PR fulfills the following requirements:
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/master/.github/Contributing.md.
What is the current behavior?
Issue Number: #3642
What is the new behavior?
Interval and IntervalAction should be created as a DTO, and call validate() to ensure the data is valid.
Does this PR introduce a breaking change?
New Imports
Specific Instructions
Are there any specific instructions or things that should be known prior to reviewing?
Other information