Display non-KRM files in kpt pkg tree output#4518
Conversation
…age tree Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Enhances kpt pkg tree to include non-KRM package files in the rendered tree output (while skipping dotfiles/dot-dirs and avoiding duplicates with KRM-rendered files).
Changes:
- Add filesystem discovery of non-KRM files and pass them into the tree renderer.
- Merge non-KRM “directories” into the tree traversal and render those filenames under each package.
- Add/adjust unit tests to validate listing, sorting, dotfile exclusion, symlink skipping, and deduplication.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| thirdparty/cmdconfig/commands/cmdtree/tree.go | Extends tree rendering to merge and print non-KRM filenames under package branches and dedup against rendered KRM resources. |
| thirdparty/cmdconfig/commands/cmdtree/cmdtree.go | Adds discoverNonKRMFiles that walks the directory tree and supplies non-KRM files to TreeWriter. |
| thirdparty/cmdconfig/commands/cmdtree/cmdtree_test.go | Updates existing expectation and adds new unit tests for non-KRM listing behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…overy and rendering Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
4a2028d to
721cf52
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
thirdparty/cmdconfig/commands/cmdtree/tree.go:112
- Parent-branch selection uses
strings.HasPrefix(pkg, parent)which can incorrectly treat sibling directories as ancestors (e.g., parent="a" matches pkg="ab"), causing the tree to nest packages/dirs under the wrong branch. Consider requiring a path-segment boundary (pkg==parent or strings.HasPrefix(pkg, parent+string(filepath.Separator))) or computing the parent viafilepath.Dir(pkg)and walking upward.
for _, pkg := range allKeys {
// create a branch for this package -- search for the parent package and create
// the branch under it -- requires that the keys are sorted
branch := tree
for parent, subTree := range treeIndex {
if strings.HasPrefix(pkg, parent) {
// found a package whose path is a prefix to our own, use this
// package if a closer one isn't found
There was a problem hiding this comment.
If we are changing the copyright, we should move it out of the thirdparty folder.
Does it make sense to do:
// Copyright 2019 The Kubernetes Authors, 2026 The kpt Authors.
? Does it work like that?
There was a problem hiding this comment.
Same here with the copyright
| // TestTreeCommand_SymlinkFileSkipped verifies symlinked files inside a package are skipped. | ||
| func TestTreeCommand_SymlinkFileSkipped(t *testing.T) { | ||
| if runtime.GOOS == "windows" { | ||
| t.SkipNow() |
There was a problem hiding this comment.
Should probably add a skip reason
There was a problem hiding this comment.
Same thing with the copyright
Summary
Enhances
kpt pkg treeto show all package files, not just KRM resources.Changes
Example
Before:
After:
Testing
AI usage disclosure