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

style: remove unused utils (#3830) #3833

Merged

Conversation

cuisongliu
Copy link
Collaborator

@cuisongliu cuisongliu commented Sep 4, 2023

(cherry picked from commit 1557b7d)
Signed-off-by: cuisongliu cuisongliu@qq.com

🤖 Generated by Copilot at 923aa6f

Summary

🛠️📄🚀

This pull request simplifies and refactors the code of several packages in the sealos project. It uses more generic and consistent functions for manipulating slices, maps, and YAML files, and avoids unnecessary type conversions and dependencies. It also improves the readability, performance, and safety of some conditions and assignments. The main packages affected are apply, env, guest, image, bootstrap, and checker. The main files changed are go.mod, pkg/apply/applydrivers/apply_drivers_default.go, pkg/apply/processor/create.go, pkg/apply/processor/interface.go, pkg/apply/run.go, pkg/apply/scale.go, pkg/apply/utils.go, pkg/env/env.go, pkg/guest/guest.go, pkg/image/merge.go, pkg/apply/gen.go, pkg/apply/processor/delete.go, pkg/apply/processor/install.go, pkg/apply/processor/scale.go, pkg/apply/reset.go, pkg/bootstrap/context.go, pkg/checker/crictl_checker.go, pkg/clusterfile/util.go, and pkg/runtime/k3s/bootstrap.go.

Sing, O Muse, of the code that was refactored
By the skillful programmers, who sought to improve
The readability and performance of their functions
That manipulate maps, slices, and YAML files.

Walkthrough

  • Replace various wrapper functions with more generic and consistent functions from the golang.org/x/exp package and the maps and stringsutil packages (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Add a new dependency to the go.mod file for the golang.org/x/exp package and remove a redundant dependency (link, link)
  • Add and remove import statements for the golang.org/x/exp/slices package and the github.com/labring/sealos/pkg/utils/strings package in various files (link, link, link, link, link, link)
  • Use the IsRootFs method of the image object instead of comparing the image type with a string constant in the NewClusterFromGenArgs function of the pkg/apply/gen.go file (link)
  • Use the GetAllLabels method of the cluster object instead of the GetImageLabels method in the NewContextFrom function of the pkg/bootstrap/context.go file (link)
  • Use a deep copy of the cluster.Spec.SSH field instead of the original field in the CheckAndInitialize function of the pkg/apply/utils.go file (link)
  • Add a check for the length of the set variable in the deleteNodes function of the pkg/apply/scale.go file (link)
  • Add a break statement to exit the loop in the Check function of the pkg/checker/crictl_checker.go file (link)
  • Use the map index operator and a check for the existence of the key in the Check function of the pkg/checker/crictl_checker.go file (link)

(cherry picked from commit 1557b7d)
Signed-off-by: cuisongliu <cuisongliu@qq.com>
@pull-request-size
Copy link

Whoa! Easy there, Partner!

This PR is too big. Please break it up into smaller PRs.

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Patch has no changes to coverable lines.

📢 Thoughts on this report? Let us know!.

@cuisongliu cuisongliu merged commit 5a65c83 into labring:release-v4.4 Sep 4, 2023
@cuisongliu cuisongliu deleted the release-v4.4-cherry-pick-error branch September 4, 2023 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error cherry-picking PR #3830
3 participants