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

feat: deserialize object from multiple yaml documents #3862

Merged
merged 2 commits into from Sep 7, 2023

Conversation

fengxsong
Copy link
Collaborator

@fengxsong fengxsong commented Sep 7, 2023

🤖 Generated by Copilot at c20caa7

Summary

♻️🔧✨

This pull request refactors the YAML handling and parsing across the project by using a new YAML utility package and a stricter unmarshaling mode. It also updates the functions that check or manipulate the configuration files of k3s, crictl, registry, and kubeadm to use the new YAML package and mode. The goal is to improve the code quality, validation, and consistency of working with YAML data and files.

Sing, O Muse, of the valiant deeds of the sealos heroes,
Who dared to tame the mighty beasts of kubernetes and k3s,
And who refined their craft with skillful tools of yaml and crictl,
And who merged and checked their configs with UnmarshalToMap and Strict.

Walkthrough

  • Replace UnmarshalData function with UnmarshalToMap function from yaml package for unmarshaling YAML data into maps in Check functions of crictl_checker.go and registry_checker.go files (link, link)
  • Clean up import statements and use yaml package in config.go file of k3s package (link)
  • Simplify and validate parsing of k3s configuration file using Unmarshal function from yaml package in config.go file of k3s package (link)
  • Replace UnmarshalData function with UnmarshalToMap function from yaml package for unmarshaling YAML data into maps in saveNewKubeadmConfig and mergeWithBuiltinKubeadmConfig functions of certs.go and kubeadm.go files of kubernetes package (link, link)
  • Rename Unmarshal function to UnmarshalToMap and add unmarshalStrict function for strict unmarshaling of YAML data into structs in yaml.go file of yaml package (link)
  • Remove unused ToYAMLs function and add Marshal function for marshaling objects into YAML data in yaml.go file of yaml package (link)
  • Modify UnmarshalFile function to use unmarshalStrict function and add IsNil function for checking nil or empty YAML data in yaml.go file of yaml package (link)

@sealos-ci-robot
Copy link
Member

sealos-ci-robot commented Sep 7, 2023

🤖 Generated by lychee action

Summary

Status Count
🔍 Total 932
✅ Successful 392
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 539
❓ Unknown 0
🚫 Errors 0

Full action output

Full Github Actions output

@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Patch has no changes to coverable lines.

📢 Thoughts on this report? Let us know!.

@cuisongliu cuisongliu merged commit 48a1d69 into labring:main Sep 7, 2023
74 checks passed
@sealos-ci-robot
Copy link
Member

/cherry-pick release-v4.4

@sealos-ci-robot
Copy link
Member

🤖 says: cherry pick action finished successfully 🎉!
See: https://github.com/labring/sealos/actions/runs/6112707850

sealos-ci-robot pushed a commit that referenced this pull request Sep 7, 2023
* feat: deserialize object from multiple yaml documents

* fix: ignore parse k3s config error
cuisongliu pushed a commit that referenced this pull request Sep 7, 2023
* feat: deserialize object from multiple yaml documents

* fix: ignore parse k3s config error

Co-authored-by: fengxsong <fengxsong@outlook.com>
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.

None yet

3 participants