Skip to content
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

Use Go standard library slices package instead of k8s.io/utils/strings/slices #126715

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

tklauser
Copy link
Contributor

The package was introduced in Go 1.21 and is already in use in the k8s code base.

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


…s/slices

The package was introduced in Go 1.21 and is already in use in the k8s
code base.
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 15, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @tklauser. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added area/kubectl sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 15, 2024
@ffromani
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 15, 2024
@@ -313,7 +313,7 @@ func (r Requirement) Equal(x Requirement) bool {
if r.operator != x.operator {
return false
}
return stringslices.Equal(r.strValues, x.strValues)
return slices.Equal(r.strValues, x.strValues)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the performance difference between the specific implementation and the generic? are we planning to remove the stringslices package?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We committed to supporting k8s.io/utils - but we could^Wshould deprecate these, or reimplement them in terms of slices, or BOTH

@BenTheElder
Copy link
Member

/cc @thockin
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 15, 2024
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be awesome to couple this with a PR against k8s.io/utils to mark these functions and maybe this whole package as deprecated, and reimplement them in terms of std slices:

e.g.

// Equal reports whether two slices are equal
// Deprecated: use slices.Equal instead
var Equal = slices.Equal

/lgtm
/approve

@@ -313,7 +313,7 @@ func (r Requirement) Equal(x Requirement) bool {
if r.operator != x.operator {
return false
}
return stringslices.Equal(r.strValues, x.strValues)
return slices.Equal(r.strValues, x.strValues)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We committed to supporting k8s.io/utils - but we could^Wshould deprecate these, or reimplement them in terms of slices, or BOTH

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 15, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 5d147bab9b7f81bf13e6f297fef9a9e124aa613a

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: thockin, tklauser

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 15, 2024
@k8s-ci-robot k8s-ci-robot merged commit 1dd3c64 into kubernetes:master Aug 16, 2024
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.32 milestone Aug 16, 2024
@tklauser tklauser deleted the use-go-stdlib-slices branch August 17, 2024 09:29
tklauser added a commit to tklauser/k8s-utils that referenced this pull request Aug 20, 2024
As suggested by Tim in [1], deprecate the functions in the
k8s.io/utils/strings/slices package that are already covered by generic
functions in the Go standard library slices package. Also reimplement
them in terms of slices functions.

[1] kubernetes/kubernetes#126715 (review)
@tklauser
Copy link
Contributor Author

It would be awesome to couple this with a PR against k8s.io/utils to mark these functions and maybe this whole package as deprecated, and reimplement them in terms of std slices:

Thanks for the review and the suggestion. I've opened the corresponding k8s.io/utils PR here: kubernetes/utils#315

tklauser added a commit to tklauser/k8s-utils that referenced this pull request Aug 21, 2024
As suggested by Tim in [1], deprecate the functions in the
k8s.io/utils/strings/slices package that are already covered by generic
functions in the Go standard library slices package. Also reimplement
them in terms of slices functions.

[1] kubernetes/kubernetes#126715 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants