feat: template consolidation, extend flow, kubeconfig#122
feat: template consolidation, extend flow, kubeconfig#122frezes merged 59 commits intokubesphere:masterfrom
Conversation
|
This PR has multiple commits, and the default merge method is: squash. DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: smartcat999 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the extension creation and management workflow by consolidating template logic, introducing a declarative specification for extensions, and enhancing the 'create' command to support incremental additions of capabilities. It also improves the 'package' and 'publish' commands with new features like ChartMuseum integration and a dedicated 'doctor' command for environment validation, aiming to provide a more robust and user-friendly developer experience. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a major refactoring of the extension creation process, consolidating templates and introducing a declarative spec-based flow. It also adds an 'extend' feature to add capabilities to existing extensions, a 'doctor' command for environment checks, and unified kubeconfig handling. The changes are well-structured and follow the provided design document. I've found a few areas with opportunities for improvement, mainly around error handling and code duplication. Overall, this is a great enhancement to the project.
| func (o *createOptions) run(c *cobra.Command, _ []string) error { | ||
| // Extend mode: if extension.yaml exists in current dir, offer to add capabilities | ||
| // Must run before any interactive prompts so users in existing extension dirs get extend options | ||
| pwd, _ := os.Getwd() |
| case "app": | ||
| from := o.from | ||
| if from == "" { | ||
| fromPrompt := inputPromptContent{ | ||
| text: "Chart file path (e.g. ./demo-0.1.0.tgz)", | ||
| errorMsg: "Chart path can't be empty", | ||
| } | ||
| from = promptGetInput(fromPrompt) | ||
| } | ||
| return extension.CreateApp(from) | ||
| case "simple": | ||
| from := o.from | ||
| if from == "" { | ||
| fromPrompt := inputPromptContent{ | ||
| text: "Chart file path (e.g. ./demo-0.1.0.tgz)", | ||
| errorMsg: "Chart path can't be empty", | ||
| } | ||
| from = promptGetInput(fromPrompt) | ||
| } | ||
| return extension.CreateSimple(from) |
There was a problem hiding this comment.
The logic for getting the from path is duplicated for the "app" and "simple" cases. This can be consolidated to reduce code duplication and improve maintainability.
case "app", "simple":
from := o.from
if from == "" {
fromPrompt := inputPromptContent{
text: "Chart file path (e.g. ./demo-0.1.0.tgz)",
errorMsg: "Chart path can't be empty",
}
from = promptGetInput(fromPrompt)
}
if typ == "app" {
return extension.CreateApp(from)
}
return extension.CreateSimple(from)| if o.repo == "" { | ||
| return fmt.Errorf("--target=chartmuseum requires --repo=<chartmuseum URL>\nHint: e.g. --repo=http://localhost:8080") | ||
| } | ||
| pwd, _ := os.Getwd() |
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| body, _ := io.ReadAll(resp.Body) |
There was a problem hiding this comment.
|
|
||
| // ExtendAddBackend adds backend capability to an existing frontend-only extension. | ||
| // root must contain extension.yaml, values.yaml, charts/frontend. | ||
| func ExtendAddBackend(root string) error { |
There was a problem hiding this comment.
There is significant code duplication between ExtendAddBackend and ExtendAddFrontend. Much of the logic for updating extension.yaml, values.yaml, and regenerating the root Makefile is repeated. This could be refactored into smaller, reusable helper functions to improve maintainability. For example, you could have helpers for updating dependencies, updating values, and copying scaffolds.
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Add dependency update before packaging when extension.yaml has dependencies. When metadata.Dependencies is non-empty, run helm dependency update after writing Chart.yaml and before LoadDir. Use --skip-dependency-update to skip. Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
- Infer version from charts/<name>/Chart.yaml when dependency lacks version - Return clear error for remote deps (repository set) without version - Fixes 'improper constraint' when using extension-samples hello-world Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
…Simple Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
P2-2: Remove namespace, externalDependencies, and init container annotations example comments from create template. Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Signed-off-by: peng wu <2030047311@qq.com>
…nd-only) P2-2b: When creating from scratch, prompt for template type. - Standard: frontend+backend (default) - Frontend only: frontend subchart only - Backend only: backend subchart only New embed dirs: templatesfrontend, templatesbackend Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
Made-with: Cursor Signed-off-by: peng wu <2030047311@qq.com>
…eadAll error Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
…endAddFrontend Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
…ase only Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
2efcad6 to
74a1f96
Compare
|
前端集成上,可以将 Hello World 项目作为示例进行集成,这里和 @donniean 讨论确认下,保留 src 及目录架构,补充增加 readme, 和 dev-guide 完整结合起来。 https://github.com/kubesphere/extension-samples/tree/master/extensions-frontend/extensions/hello-world |
Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
…e pullPolicy in values Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
…ev-guide README, workflow hints Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
d8e9801 to
6c3d91b
Compare
- Keep generated path as <ext>/frontend/ with workspace root from extension-samples (yarn.lock, babel, configs, tool configs). - Per-extension scaffold under frontend/extensions/<name>/ from templates/frontend/extensions/scaffold. - copyFrontendWorkspace skips scaffold when copying workspace; ExtendAddFrontend uses same materialization. - SystemJS shell lives in src/console-shell.js; dist/index.js via npm run build:shell and Docker stage. - Update tests and .gitignore for new paths. Signed-off-by: peng wu <2030047311@qq.com>
6c3d91b to
aa1b2e4
Compare
Only render the frontend or backend block in generated values.yaml when that capability is enabled, so frontend-only scaffolds no longer carry a backend section. Also stop precreating frontend/configs/extensions and align tests/docs with the generated layout. Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Trim leading newlines from ValuesYAML output so backend-only or frontend-only scaffolds start directly with their section key. Add a regression test to ensure values.yaml never begins with an empty line. Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Generate backend dependency without tags for backend-only extensions, while keeping the existing agent tag for mixed frontend+backend mode. Add regression checks for both cases. Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
Set installationMode to Multicluster only when both frontend and backend are enabled. Backend-only extensions now stay HostOnly, and related generator/create tests are updated accordingly. Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
- Document frontend/ workspace and frontend/extensions/<name>/ - Update frontend chart template list and JSBundle example - Note values.yaml trimming and installationMode rules - Fix create success hint path to per-extension README Signed-off-by: peng wu <2030047311@qq.com> Made-with: Cursor
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: 53adebf2f7a58eae29d3f972a5ab8b9ceda806b0 |
Closes kubesphere/project#7345
Release note
Summary
Addresses Issue #7345 and P2 items:
createapp/createsimplewithcreate --type=app|simple --from=<chart>--kubeconfigpersistent flag and unified resolution for publish/unpublish/templatepublish --target=chartmuseumwith--repo,--username,--password; TLS support via--ca-bundleand--insecure-skip-tls-verifyksbuilder templateerror hints and examples--skip-dependency-updateksbuilder doctorto check Go, Helm, kubectl, ksbuilder, kubeconfigksbuilder create; offer to add missing frontend/backend viaExtendAddFrontend/ExtendAddBackendTest Plan
go test ./pkg/extension ./pkg/extension/generator ./cmd/...ksbuilder create --type=standardksbuilder create --type=app --from=./chart.tgzksbuilder create --type=simple --from=./chart.tgzksbuilder package <dir>ksbuilder doctor