Skip to content

feat: add -o yaml and -o json to tkn version - #3299

Merged
tekton-robot merged 1 commit into
tektoncd:mainfrom
anwesha-palit-redhat:feat/SRVKP-13110
Sep 28, 2026
Merged

tekton-robot merged 1 commit into
tektoncd:mainfrom
anwesha-palit-redhat:feat/SRVKP-13110

Conversation

@anwesha-palit-redhat

Copy link
Copy Markdown
Contributor

Changes

Added -o/--output support to tkn version.

  • Supports json and yaml output for tkn version.
  • Supports structured output with --component.
  • Default output remains unchanged.
  • Invalid output formats and component values return clear errors.

Examples:

$ tkn version -o json
{
    "client": "dev",
    "dashboard": "devel",
    "pipeline": "devel"
}
$ tkn version --component pipeline -o yaml
pipeline: devel

Submitter Checklist

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

See [[the contribution guide](https://github.com/tektoncd/cli/blob/main/CONTRIBUTING.md)](https://github.com/tektoncd/cli/blob/main/CONTRIBUTING.md) for more details.

Release Notes

`tkn version` now supports `--output json` and `--output yaml`, including with `--component`.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 24, 2026
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 24, 2026
@divyansh42
divyansh42 requested a balanced review from Copilot September 24, 2026 12:13

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

The no-kubeconfig path rejects the valid hub component, and the generated examples are incorrectly formatted.

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 JSON/YAML output support to tkn version, including component-specific output.

Changes:

  • Adds -o json|yaml and validation.
  • Adds structured-output tests.
  • Regenerates command and manpage documentation.
File Description
pkg/​cmd/​version/​version.go Implements structured version output.
pkg/​cmd/​version/​version_test.go Tests formats, components, and errors.
docs/​man/​man1/​tkn-version.1 Updates generated manpage.
docs/​cmd/​tkn_version.md Updates generated command reference.

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

Comment thread pkg/cmd/version/version.go Outdated
Comment thread pkg/cmd/version/version.go Outdated

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

Invalid components can still exit successfully, and the new examples generate malformed documentation formatting.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)

Comment thread pkg/cmd/version/version.go Outdated
@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 25, 2026

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

Changes looks good to me.

One small observation (not blocking): the if formatted.IsStructured(output) check is now repeated for every component case, which adds quite a bit of duplication. This pattern was already there before your PR, but it got amplified. Might be worth filing a follow-up issue to refactor this later - something like collecting all the version data first, then deciding how to output it once. Would cut down a lot of the repetitive code. But that's definitely a separate cleanup task, not something to hold up this PR.

Comment thread docs/cmd/tkn_version.md
@divyansh42

Copy link
Copy Markdown
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 28, 2026
Allow `tkn version -o json|yaml` and allow the same with --component.
Signed-off-by: Anwesha Palit [apalit@redhat.com]
Assisted-by: Grok 4.6 via Cursor
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 28, 2026
@divyansh42

Copy link
Copy Markdown
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 28, 2026
@tekton-robot
tekton-robot merged commit 6b8f75e into tektoncd:main Sep 28, 2026
12 checks passed
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