Skip to content

Display non-KRM files in kpt pkg tree output#4518

Open
aravindtga wants to merge 2 commits into
kptdev:mainfrom
Nordix:tree-show-non-krm-resources
Open

Display non-KRM files in kpt pkg tree output#4518
aravindtga wants to merge 2 commits into
kptdev:mainfrom
Nordix:tree-show-non-krm-resources

Conversation

@aravindtga
Copy link
Copy Markdown
Contributor

Summary

Enhances kpt pkg tree to show all package files, not just KRM resources.

Changes

  • Walk the package tree to discover non-KRM files and render them in the tree output
  • Deduplicate files already rendered as KRM resources (by basename)
  • Skip dotfiles and dot-directories (.git/, .hidden)

Example

Before:

  Package "my-app"
  ├── [Kptfile]  Kptfile my-app
  ├── [deployment.yaml]  Deployment nginx
  └── Package "subpkg"
      ├── [Kptfile]  Kptfile subpkg
      └── [service.yaml]  Service my-svc

After:

  Package "my-app"
  ├── [Kptfile]  Kptfile my-app
  ├── [deployment.yaml]  Deployment nginx
  ├── README.md
  └── Package "subpkg"
      ├── [Kptfile]  Kptfile subpkg
      ├── [service.yaml]  Service my-svc
      └── NOTES.txt

Testing

  • Manually tested with multiple package structures
  • Added unit tests

AI usage disclosure

  • AI assistance (Kiro CLI) was used to draft portions of this change, and this PR description.

…age tree

Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 12, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 721cf52
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a047bf9dfb0d80009190fc9
😎 Deploy Preview https://deploy-preview-4518--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@aravindtga aravindtga marked this pull request as ready for review May 12, 2026 16:47
Copilot AI review requested due to automatic review settings May 12, 2026 16:47
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request go Pull requests that update Go code labels May 12, 2026
Copy link
Copy Markdown
Contributor

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

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.

Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree.go Outdated
Comment thread thirdparty/cmdconfig/commands/cmdtree/tree.go
Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree.go Outdated
Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree.go Outdated
Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree_test.go
Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree_test.go
Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree_test.go
Comment thread thirdparty/cmdconfig/commands/cmdtree/tree.go
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

Comment thread thirdparty/cmdconfig/commands/cmdtree/tree.go Outdated
Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree.go
Comment thread thirdparty/cmdconfig/commands/cmdtree/cmdtree_test.go Outdated
…overy and rendering

Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
Copy link
Copy Markdown
Contributor

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

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 via filepath.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update Go code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants