Skip to content

feat: Support XDG base directory for bundle cache - #3296

Merged
tekton-robot merged 1 commit into
tektoncd:mainfrom
chmouel:support-xdg-bundle-cache
Sep 23, 2026
Merged

tekton-robot merged 1 commit into
tektoncd:mainfrom
chmouel:support-xdg-bundle-cache

Conversation

@chmouel

@chmouel chmouel commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Changes

Adds support for the XDG Base Directory Specification when resolving the default bundle cache directory.

When --cache-dir is not set, tkn picks the default in this order:

  1. ~/.tekton/bundles, if ~/.tekton already exists (kept for backward compatibility)
  2. $XDG_CACHE_HOME/tkn/bundles, if XDG_CACHE_HOME is set to an absolute path
  3. ~/.cache/tkn/bundles otherwise

It also replaces the mitchellh/go-homedir dependency with a small internal ~ expansion helper (pkg/bundle/cache_dir.go), and --cache-dir now rejects an empty value instead of silently caching in the current directory.

See this article why repescting XDG is important (event on OSX/WSL): https://maex.me/2019/12/the-power-of-the-xdg-base-directory-specification/

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

Release Notes

`tkn bundle list` now follows the XDG Base Directory Specification for its default cache location: `$XDG_CACHE_HOME/tkn/bundles`, or `~/.cache/tkn/bundles` if unset. It falls back to the legacy `~/.tekton/bundles` only when that directory already exists.

NOTE: I have used AI for implementing this feature but reviewed it myself, gpt-6-luna

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Sep 23, 2026
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 23, 2026
@chmouel
chmouel marked this pull request as ready for review September 23, 2026 05:56
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 23, 2026
@chmouel
chmouel requested a balanced review from Copilot September 23, 2026 05:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Relative XDG paths incorrectly fail instead of being ignored, and the displayed static default contradicts runtime selection.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds XDG-aware default bundle-cache resolution while preserving legacy cache compatibility.

Changes:

  • Adds cache-directory resolution and ~ expansion.
  • Rejects empty --cache-dir values and expands test coverage.
  • Updates CLI help and generated documentation.
File Description
pkg/​bundle/​cache_dir.go Implements cache-path selection.
pkg/​bundle/​cache_dir_test.go Tests cache-path precedence.
pkg/​bundle/​flags.go Adds validated cache flag handling.
pkg/​bundle/​remote.go Applies resolved cache paths.
pkg/​bundle/​remote_test.go Tests caching integration.
pkg/​cmd/​bundle/​list.go Updates cache help text.
pkg/​cmd/​bundle/​list_test.go Tests explicit and empty flags.
docs/​cmd/​tkn_bundle_list.md Updates generated command documentation.
docs/​man/​man1/​tkn-bundle-list.1 Updates generated manpage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/bundle/cache_dir.go
Comment thread pkg/bundle/flags.go Outdated
Supported the XDG Base Directory Specification for the bundle cache. The
cache directory defaulted to the legacy `~/.tekton/bundles` path only
when the `~/.tekton` directory already existed. Otherwise, it used
`$XDG_CACHE_HOME/tkn/bundles` or `~/.cache/tkn/bundles`.

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The cache-selection behavior, validation, tests, and generated documentation are consistent and complete.

Review effort: Balanced
Findings: None

Resolved since last review (2)

@divyansh42 divyansh42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 23, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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

The pull request process is described 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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 23, 2026
@tekton-robot
tekton-robot merged commit 667b551 into tektoncd:main Sep 23, 2026
13 checks passed
@chmouel
chmouel deleted the support-xdg-bundle-cache branch September 23, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants