-
Notifications
You must be signed in to change notification settings - Fork 253
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
Refactoring of image compatibility node validator #2028
Refactoring of image compatibility node validator #2028
Conversation
Hi @mfranczy. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for kubernetes-sigs-nfd ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/hold The PR is ready for review, but I want to be 110% sure I didn't break anything.. still running tests. |
d7a5d3d
to
c402435
Compare
for _, term := range featureMatcher { | ||
if term.MatchExpressions != nil { | ||
out = append(out, matchExpressions(term, matchedFeatureTerms)...) | ||
} |
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.
continue to next loop if matchExpressions has been appended? not rely on if term.MatchExpressions != nil then term.MatchName must be nil
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.
It's allowed to define matchExpressions
and matchName
at the same time. Both cases have to be checked before the next iteration.
c402435
to
b8c0924
Compare
/hold cancel The code works as expected. |
if matchStatus.MatchAny[i].MatchedFeaturesTerms != nil { | ||
matchedFeatureTermsAny = matchStatus.MatchAny[i].MatchedFeaturesTerms |
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.
nit: just caught my eye, small readability improvement (imo)
if matchStatus.MatchAny[i].MatchedFeaturesTerms != nil { | |
matchedFeatureTermsAny = matchStatus.MatchAny[i].MatchedFeaturesTerms | |
if t := matchStatus.MatchAny[i].MatchedFeaturesTerms; t != nil { | |
matchedFeatureTermsAny = t |
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.
Fixed.
if matchStatus.MatchFeatureStatus != nil { | ||
matchedFeatureTerms = matchStatus.MatchFeatureStatus.MatchedFeaturesTerms | ||
} |
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.
nit: just caught my eye, small readability improvement (imo)
if matchStatus.MatchFeatureStatus != nil { | |
matchedFeatureTerms = matchStatus.MatchFeatureStatus.MatchedFeaturesTerms | |
} | |
if m := matchStatus.MatchFeatureStatus; m != nil { | |
matchedFeatureTerms = m.MatchedFeaturesTerms | |
} |
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.
Fixed.
Version: compatv1alpha1.Version, | ||
Compatibilties: []compatv1alpha1.Compatibility{ | ||
|
||
Convey("That contains flag which results in match", func() { |
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.
nit: with the new convey here, should the one above be changed to something like
Convey("With a single compatibility set", t func() {
Would it make more sense?
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.
Yes, fixed.
/ok-to-test |
Additionally, testcases have been separated into distinct functions for better readability. Signed-off-by: Marcin Franczyk <[email protected]>
b8c0924
to
99d63d3
Compare
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.
Looks good to me
ping @ChaoyiHuang @ArangoGutierrez
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: marquiz, mfranczy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM, sorry for the holiday break |
NP, thanks @ChaoyiHuang |
LGTM label has been added. Git tree hash: 2bdfadf8010d8aa4f411fcabcad95a209362fc0e
|
I refactored the node validator code to achieve better readability for easier maintenance / expansion.
In addition, test cases have been moved into separate functions, before in case of failure, it was hard to figure out what's wrong.