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
(#17917) Allow regexp confines #371
Conversation
@dalen Can you clean up that test file? The long list of confines that is used across all of those tests makes it hard to follow what each case is that it is checking. |
I've separated the confine creations for each test so it is a bit more clear what each test case is tesing. And fixed one of them so it actually tests what it says it is testing (if any of the provided symbol values matches the fact's string value). |
@dalen Thanks for doing that, it is a lot nicer now. There ends up being a lot of duplication between the tests, which is what the one
Those three things together entirely define the test and should be called out more clearly. Maybe something like:
|
Also cleaned up the spec tests around confines a bit.
okay, updated a bit. |
Great! Thanks for doing that. I'm going to hand this over to @jeffmccune to finish it off. |
return true if value == v | ||
end | ||
return false | ||
return @values.any? { |v| convert(v) === value } |
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.
This entire patch is great. My only comment is that the commit message doesn't closely align with the implementation. True, this patch provides regular expression confinement functionality, but it does so by implementing Case Equality matching, of which regular expression matching is a subset.
I've simply updated the commit message to more closely align the change in code with the description of what we're changing. No action required to get this merged.
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.
Here's the new commit message:
(#17917) Allow case equality confinement matching
Without this patch applied the confine functionality is limited to
testing equality. This is a problem because some facts have different,
but similar, values over time. For example, the use case motivating
this feature is:
I have some facts I want to run on all generations of dell machines,
but the manufacturer fact has changed between them so I want to be
able to use something like /.*Dell.*/
This patch implements case equality which provides a superset of the
regular expression matching that addresses the problem.
This patch also cleans up the spec tests around confines a bit.
MergedInto 1.7.x as a0b1acb. This will be released in Facter 1.7.0 and 2.0.0. Thanks for the contribution Erik, please keep 'em coming! -Jeff |
No description provided.