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

feature: sealos create support for environment variable based template rendering #4222

Merged
merged 9 commits into from
Nov 2, 2023

Conversation

LZiHaN
Copy link
Contributor

@LZiHaN LZiHaN commented Nov 1, 2023

🤖 Generated by Copilot at 4a8d504

Summary

📝🆕🎨

This pull request adds a new feature to the sealos create command that enables users to customize the cluster image with environment variables. It updates the pkg/buildah package to handle the rendering of template files with the given variables. It also updates the English and Chinese documentation of the command to explain and demonstrate the new option -e.

sealos create -e
Render cluster with env vars
Autumn leaves template

Walkthrough

  • Add a new option -e, --env=[] to the sealos create command that allows users to specify environment variables for template rendering (link, link, link, link)
  • Modify the example of the sealos create command in the documentation to include the -e option and explain its usage (link, link)
  • Import the context, file, and errgroup packages in pkg/buildah/create.go to handle concurrent tasks and file operations (link, link)
  • Add a conditional block to the create function in pkg/buildah/create.go that calls the runRender function if the env field is not empty (link)
  • Add a new function runRender in pkg/buildah/create.go that uses the errgroup package to run multiple goroutines that render the template files in the cluster image with the template package (link)
  • Add a new function RenderTemplatesWithEnv in pkg/buildah/util.go that renders the template files in the etc, scripts, and manifests subdirectories of a given file path with the template package and the environment variables (link)
  • Add some new imports to the pkg/buildah/util.go file that are used by the RenderTemplatesWithEnv function (link)

refer to #3774

Supporting documentation:
https://sealos.io/docs/self-hosting/lifecycle-management/operations/build-image/build-image-go_template
https://sealos.io/docs/self-hosting/lifecycle-management/advanced-guide/template-function
https://sealos.io/docs/self-hosting/lifecycle-management/reference/sealos/app-cluster-image

@sealos-ci-robot
Copy link
Member

sealos-ci-robot commented Nov 1, 2023

🤖 Generated by lychee action

Summary

Status Count
🔍 Total 970
✅ Successful 377
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 592
❓ Unknown 0
🚫 Errors 0

Full action output

Full Github Actions output

Copy link

sweep-ai bot commented Nov 1, 2023

Apply Sweep Rules to your PR?

  • Apply: Leftover TODOs in the code should be handled.
  • Apply: All new business logic should have corresponding unit tests in the tests/ directory.
  • Apply: Any clearly inefficient or repeated code should be optimized or refactored.

@sealos-ci-robot
Copy link
Member

sealos-ci-robot commented Nov 1, 2023

📘 Preview documentation website

👀 Visit Preview

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
pkg/env/env.go 64.40% <100.00%> (+11.59%) ⬆️

📢 Thoughts on this report? Let us know!.

pkg/buildah/create.go Show resolved Hide resolved
pkg/buildah/util.go Outdated Show resolved Hide resolved
@cuisongliu cuisongliu merged commit 25ac669 into labring:main Nov 2, 2023
82 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/6734938619

sealos-ci-robot pushed a commit that referenced this pull request Nov 2, 2023
…ate rendering (#4222)

* feature: environment variable based template rendering in sealos create

* add: goimports tools

* update: goimports tools

* update: goimports tools

* fix golangci lint error

* remove docs

* remove docs

* fix: refactor template rendering logic, abstract common func

* fix ci
cuisongliu pushed a commit that referenced this pull request Nov 2, 2023
…ate rendering (#4222) (#4232)

* feature: environment variable based template rendering in sealos create

* add: goimports tools

* update: goimports tools

* update: goimports tools

* fix golangci lint error

* remove docs

* remove docs

* fix: refactor template rendering logic, abstract common func

* fix ci

Co-authored-by: Zihan Li <eden.zh.li@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.

3 participants