Skip to content

Show independent/dependent package type in pkg tree output - #4668

Open
aravindtga wants to merge 1 commit into
kptdev:mainfrom
Nordix:pkg-tree-show-package-type
Open

Show independent/dependent package type in pkg tree output#4668
aravindtga wants to merge 1 commit into
kptdev:mainfrom
Nordix:pkg-tree-show-package-type

Conversation

@aravindtga

Copy link
Copy Markdown
Contributor

Description

  • What changed: The kpt pkg tree command now annotates packages with (independent) or (dependent) based on whether their Kptfile contains an upstream section.
  • Why it's needed: When exploring a package hierarchy, it's not immediately clear which subpackages can be updated independently and which are managed as part of their parent. This requires manually inspecting each Kptfile. Surfacing this in pkg tree makes package composition visible at a glance.
  • How it works: A new packageType() function in thirdparty/cmdconfig/commands/cmdtree/tree.go reads each package's Kptfile (using lenient YAML decoding) and checks for the presence of the Upstream field. Subpackages are always annotated; root packages only show (independent) when they have an upstream source, a locally created root (e.g. via kpt pkg init) shows no annotation since it has no parent to be "dependent" on.

Related Issue(s)

Type of Change

  • Bug fix
  • New feature
  • Enhancement
  • Refactor
  • Documentation
  • Tests
  • Other: ________

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:
- Kiro to analyse the issue, validate/update the changes, write tests, and update documentation.

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

netlify Bot commented Jul 28, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit d254d98
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a68966df2f2a50008aa2f19
😎 Deploy Preview https://deploy-preview-4668--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.

@sonarqubecloud

Copy link
Copy Markdown

@aravindtga
aravindtga marked this pull request as ready for review July 28, 2026 11:56
@aravindtga
aravindtga requested review from a team July 28, 2026 11:56
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. area/pkg documentation Improvements or additions to documentation enhancement New feature or request labels Jul 28, 2026
@liamfallon
liamfallon requested a review from Copilot July 28, 2026 16:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR updates kpt pkg tree output to annotate packages as (independent) or (dependent) based on whether their Kptfile contains an upstream section, making package update boundaries visible directly in the tree output.

Changes:

  • Add Kptfile parsing to determine and display package type in pkg tree output (root annotated only when independent).
  • Update/extend tests to validate independent/dependent annotations (including nested subpackages).
  • Update CLI reference + book/guides to document the new annotations and show updated examples.

Reviewed changes

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

Show a summary per file
File Description
thirdparty/cmdconfig/commands/cmdtree/tree.go Adds package-type detection by reading/parsing Kptfiles and annotating tree output.
thirdparty/cmdconfig/commands/cmdtree/cmdtree_test.go Updates existing expectations and adds new coverage for independent/dependent behavior.
documentation/content/en/reference/cli/pkg/tree/_index.md Documents annotations and adds an example output snippet.
documentation/content/en/guides/namespace-provisioning-cli.md Updates example output to include (independent).
documentation/content/en/book/03-packages/_index.md Updates book examples to include (independent)/(dependent).
documentation/content/en/book/02-concepts/_index.md Updates concept examples to include (independent)/(dependent).
documentation/content/en/book/01-getting-started/_index.md Updates getting-started example to include (independent).

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

Comment on lines +226 to 240
func packageType(dir string) string {
data, err := os.ReadFile(filepath.Join(dir, kptfilev1.KptFileName))
if err != nil {
return ""
}
var kf kptfilev1.KptFile
d := yaml.NewDecoder(bytes.NewReader(data))
if err := d.Decode(&kf); err != nil {
return ""
}
if kf.Upstream != nil {
return PkgTypeIndependent
}
return name
return PkgTypeDependent
}
Comment on lines +187 to +192
pkgType := packageType(p.Root)
if pkgType == PkgTypeIndependent {
tree.SetValue(fmt.Sprintf(PkgNameFormat+" (%s)", filepath.Base(p.Root), pkgType))
} else {
tree.SetValue(fmt.Sprintf(PkgNameFormat, filepath.Base(p.Root)))
}
Comment on lines +65 to +66
├── [deployment.yaml] Deployment wordpress-mysql
└── [deployment.yaml] Service wordpress-mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/pkg documentation Improvements or additions to documentation enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tree command should optionally (?) show whether a package is dependent or independent

2 participants