-
Notifications
You must be signed in to change notification settings - Fork 351
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
Moved and renamed all Predicate names and Filter names for consistency and ease of use #1828
Moved and renamed all Predicate names and Filter names for consistency and ease of use #1828
Conversation
afa1871
to
8d2e3c0
Compare
@peterklijn Hello, thank you for the contribution. I can see the point of having all names in one place but I do not know why we have it like it is in the first place so lets have an opinion from other maintainers. What is a reason to leave deprecated names (like Existing codebases would break at compile time and need to be adjusted if they used moved constants. |
Thanks Alexander, happy to hear that you like it!
I actually moved them initially but the staticcheck didn't allow it as it detect calling deprecated constants from other package.
Yeah that's the only issue I could think of as well. |
Hi @AlexanderYastrebov, do you think this PR could get merged? |
8d2e3c0
to
17752d8
Compare
@AlexanderYastrebov and @szuecs, could this PR get merged please? |
@peterklijn does it break for library users? We can always merge it to the v1 branch, but right now no one is keeping it up to date, but I think we would do a rebase on master as soon as we have a need to do a v1 release. |
Hi Sandor, thanks for your quick reply!
That's a fair point. I guess technically it is a breaking change, as the public constants have been moved, and renamed for consistency. However it does not change the behaviour. What are your policies around such changes? I was hoping it would be fine to update from 1.13.x. to 1.14.0. Have all minor (major.minor.patch) updates have been without such breaking changes? If this PR was changing the behaviour, like how the Path predicate would behave for example, I fully agree it would be a breaking change and it should be a major update.
This depends on when you're expecting to release a v1. I don't think this change justifies such a big release so it would stay on that branch for quite some time. Alternative approach If you don't think this change is acceptable for a minor release, I have an alternative solution and would like to get your opinion on it before I start working on it :) I'm taking this file as an example: https://github.com/zalando/skipper/pull/1828/files#diff-66a56656328ff9986ec456542c48bda5aa5f21008b75dc64c15341a063001188 It changed from this: const (
Name = "apiUsageMonitoring" // <-- removed
unknownPlaceholder = "{unknown}"
noMatchPlaceholder = "{no-match}"
noTagPlaceholder = "{no-tag}"
)
var (
log = logrus.WithField("filter", Name)
regCache = sync.Map{}
) To this: const (
unknownPlaceholder = "{unknown}"
noMatchPlaceholder = "{no-match}"
noTagPlaceholder = "{no-tag}"
)
var (
log = logrus.WithField("filter", filters.ApiUsageMonitoringName) // <-- use constant from filters package
regCache = sync.Map{}
) Instead I can change it to this: const (
// Deprecated, use filters.ApiUsageMonitoringName instead
Name = filters.ApiUsageMonitoringName // <-- Leave but mark as deprecated
unknownPlaceholder = "{unknown}"
noMatchPlaceholder = "{no-match}"
noTagPlaceholder = "{no-tag}"
)
var (
log = logrus.WithField("filter", filters.ApiUsageMonitoringName) // <-- keep using constant from filters package
regCache = sync.Map{}
) This way, it is no longer a breaking change, as all the old constants are still there, but because they're marked as WDYT? |
@peterklijn I like the idea, that you outlined in "Alternative approach". The bigger question about if this is a minor release increase, I can answer in my opinion: I would also like to have a buy-in by other maintainers like before I let you work too much on this topic. @AlexanderYastrebov @aryszka @marcinzaremba wdyt about the introduced change in this PR (it's many files but there are only filters/filters.go and predicate/predicates.go which are interesting and the others are all similar)? |
Hi @peterklijn , thanks a lot for the change. This refactoring makes a lot of sense to me, and many thanks for being considerate and splitting up the changes that you're planning. It was an easy review. ❤️ My principle regarding such changes is that we try not to make any assumptions on who and how they use our packages. This means that we assume that there can be people who use our packages in alternative ways and they cannot be contacted. We also assume such projects have automatic builds, so the release notes is not a completely clean solution. This also means that we always try to maintain backwards compatibility of the public interfaces of the packages. With that said, to me your alternative suggestion is clearly the right way to go, ( Cheers, |
2fc4213
to
f588346
Compare
Hi @AlexanderYastrebov, @szuecs and @aryszka, Ps, I recommend that you hide whitespace changes to make the review a bit easier |
👍 |
👍 |
Moved all predicate name constants to the predicate package, added constants for the predicates that used string values. By having all predicates in the same place, with consistent naming, it makes it easier to use Predicates if you use Skipper as a Library and build routes using code. Signed-off-by: Peter Klijn <[email protected]>
Signed-off-by: Peter Klijn <[email protected]>
Moved all filter name constants to the filters package, added constants for the filters that used string values. By having all filters in the same place, with consistent naming, it makes it easier to use Filters if you use Skipper as a Library and build routes using code. Signed-off-by: Peter Klijn <[email protected]>
Signed-off-by: Peter Klijn <[email protected]>
marking old public constants as deprecated Signed-off-by: Peter Klijn <[email protected]>
Fixed the following staticcheck errors: filters/auth/grantcallback.go:11:1: comment on exported const GrantCallbackName should be of the form "GrantCallbackName ..." (ST1022) filters/auth/grantclaimsquery.go:12:1: comment on exported const GrantClaimsQueryName should be of the form "GrantClaimsQueryName ..." (ST1022) filters/diag/absorb.go:14:1: comment on exported const AbsorbName should be of the form "AbsorbName ..." (ST1022) filters/diag/absorb.go:17:1: comment on exported const AbsorbSilentName should be of the form "AbsorbSilentName ..." (ST1022) filters/rfc/rfc.go:8:1: comment on exported const Name should be of the form "Name ..." (ST1022) filters/tee/teeloopback.go:9:1: comment on exported const FilterName should be of the form "FilterName ..." (ST1022) predicates/cookie/cookie.go:14:1: comment on exported const Name should be of the form "Name ..." (ST1022) predicates/methods/methods.go:29:1: comment on exported const Name should be of the form "Name ..." (ST1022) Signed-off-by: Peter Klijn <[email protected]>
b549378
to
8e6b2da
Compare
Signed-off-by: Peter Klijn <[email protected]>
8e6b2da
to
a3d4b83
Compare
👍 |
1 similar comment
👍 |
When using Skipper as a Library, it is hard to find the constants that hold the various predicate and filter names:
predicates
package.<predicate name>Name
Name
(and rely on the package name)FilterName
orPredicateName
(and rely not the package name)In this PR I moved all predicate and filter name constants to the predicates and filters packages, added constants for the predicates and filters that used string values.
By having all predicates and filters in the same place, with consistent naming, it makes it easier to use Predicates if you use Skipper as a Library and build routes using code.
In this PR all names are the same as the actual Predicate and Filter names in the documentation, ending with a
Name
suffix as it was the most common pattern.The other reason of this PR is that I would like to continue with building helpers for Filters and Predicates (#1537), and would like to prevent a single massive PR, which is hard to review.
With this change out of the way, it makes the following changes smaller :)