Skip to content

Add support for symlink in package command#120

Merged
wansir merged 3 commits intokubesphere:masterfrom
knktc:feature-supports-symbolic-link-for-charts
Jan 19, 2026
Merged

Add support for symlink in package command#120
wansir merged 3 commits intokubesphere:masterfrom
knktc:feature-supports-symbolic-link-for-charts

Conversation

@knktc
Copy link
Copy Markdown
Contributor

@knktc knktc commented Jan 19, 2026

What this PR does / why we need it:

English:
This PR fixes the symlink handling issue in the package command. When packaging extensions that contain symbolic links in the charts directory, the original implementation would copy the symlinks themselves rather than their target contents. This caused Helm's loader.LoadDir() to fail when trying to resolve these symlinks in the temporary directory, as the original paths were no longer accessible.

The fix adds the OnSymlink option to the copy.Copy() function, configuring it to follow symlinks and copy the actual content (using copy.Deep). This ensures that all files are properly resolved and accessible when Helm loads the chart.

中文:
此 PR 修复了 package 命令中的软链接处理问题。当打包包含软链接的扩展(在 charts 目录中)时,原始实现会复制软链接本身而不是它们指向的目标内容。这导致 Helm 的 loader.LoadDir() 在尝试解析临时目录中的软链接时失败,因为原始路径已经不可访问。

修复方法是为 copy.Copy() 函数添加 OnSymlink 选项,配置其跟随软链接并复制实际内容(使用 copy.Deep)。这确保了 Helm 加载 chart 时所有文件都能被正确解析和访问。

Does this PR introduced a user-facing change?

Fixed: The package command now properly handles symbolic links in the charts directory, resolving them to their target content instead of copying the symlinks themselves.
修复:package 命令现在可以正确处理 charts 目录中的软链接,将其解析为目标内容而不是复制软链接本身。

Copilot AI review requested due to automatic review settings January 19, 2026 06:18
@kubesphere-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: knktc
Once this PR has been reviewed and has the lgtm label, please assign wansir for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@kubesphere-prow
Copy link
Copy Markdown

Welcome @knktc! It looks like this is your first PR to kubesphere/ksbuilder 🎉

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @knktc, 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 resolves a critical issue in the package command that prevented the proper packaging of Helm charts containing symbolic links. By configuring the file copying mechanism to follow and deep-copy the content pointed to by symlinks, it ensures that all necessary chart files are correctly included and accessible, thereby enabling successful chart loading by Helm.

Highlights

  • Symlink Handling in Package Command: The pull request addresses an issue where the package command incorrectly handled symbolic links within the charts directory. Previously, it copied the symlinks themselves instead of their target content, leading to failures when Helm's loader.LoadDir() attempted to resolve them.
  • Implementation of Deep Copy for Symlinks: The fix involves modifying the copy.Copy() function call in cmd/package.go to include the OnSymlink: copy.Deep option. This ensures that when a symbolic link is encountered, its actual target content is copied, allowing Helm to correctly load the chart.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubesphere-prow kubesphere-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 19, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR fixes an issue where symbolic links were not handled correctly by the package command. By using the copy.Deep option, symlinks are now dereferenced, and their content is copied, which resolves the issue of Helm being unable to load charts from the temporary directory. The change is correct and well-focused. I've added one suggestion to improve code clarity by following a common Go idiom.

Comment thread cmd/package.go Outdated
Comment on lines +52 to +54
OnSymlink: func(src string) copy.SymlinkAction {
return copy.Deep
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For better code clarity and to adhere to Go idioms, it's recommended to use the blank identifier _ for the unused src parameter. This makes it explicit that the parameter is intentionally ignored and can help avoid potential linter warnings.

Suggested change
OnSymlink: func(src string) copy.SymlinkAction {
return copy.Deep
},
OnSymlink: func(_ string) copy.SymlinkAction {
return copy.Deep
},
References
  1. In Go, it is idiomatic to use the blank identifier _ for function parameters that are not used. This explicitly communicates that the parameter is being ignored and can prevent compiler/linter warnings about unused variables.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes symlink handling in the package command by configuring the copy operation to follow symlinks and copy their target content instead of copying the symlinks themselves. This ensures Helm can properly load charts when extensions contain symbolic links in the charts directory.

Changes:

  • Modified the copy.Copy() call to include an Options parameter with an OnSymlink callback that returns copy.Deep, instructing the copy library to follow symlinks and copy the actual file content

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/package.go Outdated
defer os.RemoveAll(tempDir) // nolint

if err = copy.Copy(p, tempDir); err != nil {
// Copy with FollowSymLink option to resolve symlinks
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The comment mentions "FollowSymLink option" but the actual implementation uses the OnSymlink callback with copy.Deep action. Consider updating the comment to be more accurate, for example: "Configure copy to follow symlinks and copy their target content"

Suggested change
// Copy with FollowSymLink option to resolve symlinks
// Configure copy to follow symlinks and copy their target content

Copilot uses AI. Check for mistakes.
Comment thread cmd/package.go Outdated
if err = copy.Copy(p, tempDir); err != nil {
// Copy with FollowSymLink option to resolve symlinks
opt := copy.Options{
OnSymlink: func(src string) copy.SymlinkAction {
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The src parameter in the OnSymlink callback is unused. Consider using an underscore instead to indicate this is intentional: func(_ string) copy.SymlinkAction

Suggested change
OnSymlink: func(src string) copy.SymlinkAction {
OnSymlink: func(_ string) copy.SymlinkAction {

Copilot uses AI. Check for mistakes.
@kubesphere-prow
Copy link
Copy Markdown

This PR has multiple commits, and the default merge method is: squash.
You can request commits to be merged using the label: tide/merge-method-merge

Details

Instructions 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.

@benjaminhuo benjaminhuo requested a review from wansir January 19, 2026 07:49
@knktc
Copy link
Copy Markdown
Contributor Author

knktc commented Jan 19, 2026

use repository instead, close

@knktc knktc closed this Jan 19, 2026
@wansir wansir reopened this Jan 19, 2026
@wansir wansir merged commit 8333d17 into kubesphere:master Jan 19, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants