feat: added support for --output json and --output yaml for cancel command for pipelinerun and taskrun - #3241
anwesha-palit-redhat wants to merge 1 commit into
Conversation
…mmand for pipelinerun and taskrun
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/hold Note: This PR depends on |
| @@ -0,0 +1,112 @@ | |||
| // Copyright © 2026 The Tekton Authors. | |||
There was a problem hiding this comment.
all of these tests can probably use table test instead (lke we do generally in other tekton code)
There was a problem hiding this comment.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
Generated command documentation is stale, and SetTypeMeta does not support pointer slices as its generic API implies.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Balanced
| tm, ok := any(&items[i]).(interface { | ||
| SetGroupVersionKind(schema.GroupVersionKind) | ||
| }) | ||
| if !ok { | ||
| continue |
| } | ||
|
|
||
| c.Flags().StringVarP(&graceCancelStatus, "grace", "", "", graceCancelDescription) | ||
| c.Flags().StringVarP(&output, "output", "o", "", formatted.OutputFlagUsage) |
| }, | ||
| } | ||
|
|
||
| c.Flags().StringVarP(&output, "output", "o", "", formatted.OutputFlagUsage) |
Changes
Added -o/--output flag to pipelinerun cancel and taskrun cancel
On success, when --output json or --output yaml is set, prints a structured result instead of the plain-text message: the examples are mentioned in the release notes
Default behavior (no --output flag) is unchanged — still prints PipelineRun cancelled:
Invalid --output values (e.g. csv) return a clear error
Error paths (e.g. cancelling an already-finished run) still return plain error text regardless of --output, so failures are never mistaken for valid structured output
Reuses the shared pkg/formatted.PrintStructuredOutput/IsStructured helpers; introduces a CancelResult{Kind, Name, Status} struct local to each command package
Updated --help examples for both commands to demonstrate -o json/-o yaml usage
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make checkmake generatedSee the contribution guide
for more details.
Release Notes
tkn pipelinerun cancel and tkn taskrun cancel now support --output json and --output yaml
Both commands accept a new -o/--output flag to print the cancellation result as structured JSON or YAML instead of plain text — useful for scripts, automation, and AI agents that need machine-readable output.
Default (no --output flag) behavior is unchanged. An unsupported format (e.g. -o csv) returns a clear error.