Skip to content

feat: add structured JSON/YAML output for delete command - #3318

Merged
tekton-robot merged 1 commit into
tektoncd:mainfrom
ankrsinha:feat/structured-output-delete
Oct 8, 2026
Merged

tekton-robot merged 1 commit into
tektoncd:mainfrom
ankrsinha:feat/structured-output-delete

Conversation

@ankrsinha

@ankrsinha ankrsinha commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2850

Changes

Add --output json/yaml (-o) structured output support for delete
command across 8 resource types:
task, pipeline, pipelinerun, customrun, eventlistener, triggerbinding,
triggertemplate, and clustertriggerbinding.

TaskRun is excluded (covered by #3086).

When used, the result is returned as machine-readable output.
-o json/-o yaml skips the confirmation prompt (same as -f) so the
command can run non-interactively.

Example:

$ tkn task delete foo bar -n ns -o json
{
    "deleted": [
        "foo",
        "bar"
    ]
}
$ tkn task delete foo -n ns -o yaml
deleted:
- foo
  • Output structure is the same for all resources.
  • Named deletes and cascade with --trs / --prs are in scope; related
    resource names are included in the result.
  • Bulk delete with flags like --all, --keep, --pipeline is not in
    scope yet; combining them with -o errors out until a follow-up adds
    structured bulk output.

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

Add --output json/yaml support for delete commands across
task, pipeline, pipelinerun, customrun, eventlistener,
triggerbinding, triggertemplate, and clustertriggerbinding.
Using -o skips the confirmation prompt.

@tekton-robot tekton-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 30, 2026
@chmouel

chmouel commented Sep 30, 2026

Copy link
Copy Markdown
Member

Thanks for adding structured output to delete. I found a few paths that still need attention: --all and pipelinerun delete --pipeline can print plain text with -o json or -o yaml; pipeline delete --prs and task delete --trs leave the related runs out of the result; and a later deletion error can hide resources already deleted, including CustomRuns. Could the structured result include every successful deletion, even when the command also returns an error?

@ankrsinha

Copy link
Copy Markdown
Contributor Author

@chmouel Thanks for the review and for catching these.

--all and pipelinerun delete --pipeline can print plain text with -o json or -o yaml

This is intentional as this PR does not focus on bulk delete (with flags like --all, --pipeline, --keep). This will be handled in a seperate PR.

pipeline delete --prs and task delete --trs leave the related runs out of the result; and a later deletion error can hide resources already deleted, including CustomRuns. Could the structured result include every successful deletion, even when the command also returns an error?

Agreed on this, i will update the PR for handling these two issues.

@ankrsinha
ankrsinha force-pushed the feat/structured-output-delete branch from d8f5d04 to 7c623e9 Compare October 1, 2026 07:01
@chmouel

chmouel commented Oct 1, 2026

Copy link
Copy Markdown
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2026
@divyansh42
divyansh42 requested a balanced review from Copilot October 5, 2026 06:05

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

Structured-output handling still permits unconfirmed bulk deletion and unreliable failure reporting.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity

Open (3)
What changed in this PR

Adds machine-readable delete results across eight Tekton resource types, advancing #2850. TaskRun support remains separate in #3086.

Changes:

  • Adds a shared deletion-result format and successful-deletion accessors.
  • Integrates JSON/YAML output, format validation, and prompt suppression.
  • Adds tests and updates generated command documentation.
File Description
pkg/​formatted/​output.go Adds the shared deletion-result format.
pkg/​formatted/​output_test.go Tests result construction and empty lists.
pkg/​deleter/​deleter.go Exposes successful deletion names.
pkg/​deleter/​deleter_test.go Tests deletion accessors.
pkg/​cmd/​triggertemplate/​delete.go Adds structured TriggerTemplate results.
pkg/​cmd/​triggertemplate/​delete_test.go Tests formats and validation.
pkg/​cmd/​triggerbinding/​delete.go Adds structured TriggerBinding results.
pkg/​cmd/​triggerbinding/​delete_test.go Tests formats and validation.
pkg/​cmd/​task/​delete.go Adds structured Task and related-deletion results.
pkg/​cmd/​task/​delete_test.go Tests formats and related deletions.
pkg/​cmd/​pipelinerun/​delete.go Adds structured named PipelineRun results.
pkg/​cmd/​pipelinerun/​delete_test.go Tests formats and partial failures.
pkg/​cmd/​pipeline/​delete.go Adds structured Pipeline and related-deletion results.
pkg/​cmd/​pipeline/​delete_test.go Tests formats and related deletions.
pkg/​cmd/​eventlistener/​delete.go Adds structured EventListener results.
pkg/​cmd/​eventlistener/​delete_test.go Tests formats and validation.
pkg/​cmd/​customrun/​delete.go Adds structured results and deletion-error tracking.
pkg/​cmd/​customrun/​delete_test.go Tests JSON, validation, and partial failures.
pkg/​cmd/​clustertriggerbinding/​delete.go Adds structured ClusterTriggerBinding results.
pkg/​cmd/​clustertriggerbinding/​delete_test.go Tests formats and validation.
docs/​man/​man1/​tkn-triggertemplate-delete.1 Updates output options and examples.
docs/​man/​man1/​tkn-triggerbinding-delete.1 Updates output options and examples.
docs/​man/​man1/​tkn-task-delete.1 Updates output options and examples.
docs/​man/​man1/​tkn-pipelinerun-delete.1 Updates output options and examples.
docs/​man/​man1/​tkn-pipeline-delete.1 Updates output options and examples.
docs/​man/​man1/​tkn-eventlistener-delete.1 Updates output options and examples.
docs/​man/​man1/​tkn-customrun-delete.1 Updates output options and examples.
docs/​man/​man1/​tkn-clustertriggerbinding-delete.1 Updates output options and examples.
docs/​cmd/​tkn_triggertemplate_delete.md Documents JSON/YAML usage.
docs/​cmd/​tkn_triggerbinding_delete.md Documents JSON/YAML usage.
docs/​cmd/​tkn_task_delete.md Documents JSON/YAML usage.
docs/​cmd/​tkn_pipelinerun_delete.md Documents JSON/YAML usage.
docs/​cmd/​tkn_pipeline_delete.md Documents JSON/YAML usage.
docs/​cmd/​tkn_eventlistener_delete.md Documents JSON/YAML usage.
docs/​cmd/​tkn_customrun_delete.md Documents JSON/YAML usage.
docs/​cmd/​tkn_clustertriggerbinding_delete.md Documents JSON/YAML usage.

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

Comment thread pkg/cmd/pipelinerun/delete.go
Comment thread pkg/cmd/customrun/delete.go
Comment thread pkg/cmd/customrun/delete.go
@divyansh42

Copy link
Copy Markdown
Member

@ankrsinha few minor feedbacks:

  1.  -o json/yaml  quietly turns on force, so the confirmation prompt is skipped. Fine for scripting, but it's not mentioned in the help text, the docs, or the PR description — people won't expect  -o json  to delete without asking.
  2.  tkn task delete --all -o json  doesn't complain, it just prints the old "All Tasks deleted" line and ignores  -o . Better to error out than accept a flag that does nothing.
  3. Nit on the description: it says  --trs / --prs  are out of scope, but  --trs  does work with structured output. Just wording, nothing to change in the code.

Add -o json/yaml flag to delete commands for task, pipeline,
pipelinerun, customrun, eventlistener, triggerbinding,
triggertemplate, and clustertriggerbinding resources.
When used, the result is returned as machine-readable output
in the format {"deleted": ["name1", "name2"]}.

Signed-off-by: Ankur Sinha <anksinha@redhat.com>
Assisted-by: Claude Opus 4.6 (via Cursor)
Signed-off-by: Ankur Sinha <anksinha@redhat.com>
@ankrsinha
ankrsinha force-pushed the feat/structured-output-delete branch from 7c623e9 to fe2d4cb Compare October 6, 2026 05:52
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2026
@ankrsinha

Copy link
Copy Markdown
Contributor Author

@ankrsinha few minor feedbacks:

1. -o json/yaml  quietly turns on force, so the confirmation prompt is skipped. Fine for scripting, but it's not mentioned in the help text, the docs, or the PR description — people won't expect  -o json  to delete without asking.

2. tkn task delete --all -o json  doesn't complain, it just prints the old "All Tasks deleted" line and ignores  -o . Better to error out than accept a flag that does nothing.

3. Nit on the description: it says  --trs / --prs  are out of scope, but  --trs  does work with structured output. Just wording, nothing to change in the code.

@divyansh42

  1. Updated the help text, docs and PR desc
  2. Added a guard so that -o with bulk delete flag throws error out before any delete. This guard can be removed later once bulk delete for -o is implemented
  3. Updated the PR desc: --trs / --prs are in scope, bulk (--all / --keep / --pipeline) is the follow-up.

@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: divyansh42

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 Oct 6, 2026
@divyansh42

Copy link
Copy Markdown
Member

/cc @chmouel @vdemeester

@divyansh42

Copy link
Copy Markdown
Member

/cc @pratap0007

@chmouel

chmouel commented Oct 8, 2026

Copy link
Copy Markdown
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 8, 2026
@tekton-robot
tekton-robot merged commit 5b032e1 into tektoncd:main Oct 8, 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants