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

Introduce Go std slices and maps lib #696

Merged
merged 2 commits into from
Nov 2, 2024

Conversation

tenzen-y
Copy link
Member

@tenzen-y tenzen-y commented Nov 2, 2024

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

The Go std library has the same functions as the collections pkg below.
So, I replace self-defined collections with Go std libs.

  • Concat -> slices.Concat
  • CloneMap -> maps.Clone
  • Contains -> slices.Contains
  • IndexOf -> slices.Index

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added 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. labels Nov 2, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 2, 2024
Copy link

netlify bot commented Nov 2, 2024

Deploy Preview for kubernetes-sigs-jobset canceled.

Name Link
🔨 Latest commit e85dc6a
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-jobset/deploys/672656ebc3d9700008026e33

Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
@tenzen-y tenzen-y force-pushed the introduce-go-std-lib branch from 79b6b3b to 4b1eddd Compare November 2, 2024 05:31
@kannon92
Copy link
Contributor

kannon92 commented Nov 2, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2024
@@ -731,7 +733,10 @@ func labelAndAnnotateObject(obj metav1.Object, js *jobset.JobSet, rjob *jobset.R
jobName := placement.GenJobName(js.Name, rjob.Name, jobIdx)

// Set labels on the object.
labels := collections.CloneMap(obj.GetLabels())
labels := maps.Clone(obj.GetLabels())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to clone the map here? similar question to the annotations clone below

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a good question.
TBH, I have the same question since we already set the constructed labels and annotations to object the below:

obj.SetLabels(labels)
obj.SetAnnotations(annotations)

I thought this redundant clone came from historical reasons.
Anyway, let me remove these clones.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.
If you want to keep these clones, let me know.

Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2024
@ahg-g ahg-g added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 2, 2024
@ahg-g
Copy link
Contributor

ahg-g commented Nov 2, 2024

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, tenzen-y

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 Nov 2, 2024
@k8s-ci-robot k8s-ci-robot merged commit 830cac0 into kubernetes-sigs:main Nov 2, 2024
12 of 13 checks passed
@tenzen-y tenzen-y deleted the introduce-go-std-lib branch November 2, 2024 17:03
@@ -731,7 +733,7 @@ func labelAndAnnotateObject(obj metav1.Object, js *jobset.JobSet, rjob *jobset.R
jobName := placement.GenJobName(js.Name, rjob.Name, jobIdx)

// Set labels on the object.
labels := collections.CloneMap(obj.GetLabels())
labels := make(map[string]string)
Copy link
Contributor

Choose a reason for hiding this comment

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

this caused a regression, see #729

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. 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants