Align set with k/k apimachinery#294
Conversation
|
Thanks @logicalhan! There’s a failure in apidiff but I don’t think it’s significant — the changes are expected (or bugs in apidiff). |
|
/hold |
It is significant because we don't know who's using this. |
The changes are listed as follows: The first two aren’t changes. The last one is fine because comparable is a superset of ordered, so any existing |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle rotten |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
93a9af8 to
9ec58aa
Compare
|
New changes are detected. LGTM label has been removed. |
This aligns the features of generic Set with the version in apimachinery. The main change is that sets can be instantiated with any comparable type, not only ordered types; as a result, SortedList() can no longer be implemented as a method, and is replaced by the List() function to match apimachinery. Signed-off-by: Stephen Kitt <skitt@redhat.com>
9ec58aa to
9156a7c
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: logicalhan, skitt The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
The The change it’s complaining about is the last one, which percolates up through the stack. But in practice I don’t think it’s a breaking API change: current code using |
Go 1.21+ provides cmp.Ordered which serves the same purpose as set's private ordered type. Signed-off-by: Stephen Kitt <skitt@redhat.com>
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
/remove-lifecycle stale |
| @@ -17,19 +17,21 @@ limitations under the License. | |||
| package set | |||
There was a problem hiding this comment.
The main obstacle for transitioning from k8s.io/apimachinery/pkg/util/sets to k8s.io/utils/set: the former uses plural and thus code has sets.New, the latter singular and thus would have to change imports to sets "k8s.io/utils/set" (ugly!) or change the code (also ugly!).
"set" is arguably the better name (there's only one set type here). Also, these files have all the commit history. Maybe we can create a mirror package k8s.io/utils/sets with a typedef Set = set.Set and function wrappers for the few functions here (New, List, KeySet)?
|
|
||
| // KeySet creates a Set[E] from a keys of a map[E](? extends interface{}). | ||
| func KeySet[E ordered, A any](theMap map[E]A) Set[E] { | ||
| // If the value passed in is not actually a map, this will panic. |
There was a problem hiding this comment.
Okay, I bite: how can theMap not be a map?
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This aligns the features of generic Set with the version in apimachinery. The main change is that sets can be instantiated with any comparable type, not only ordered types; as a result, SortedList() can no longer be implemented as a method, and is replaced by the List() function to match apimachinery.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: