feat: add structured JSON/YAML output for list commands - #3242
feat: add structured JSON/YAML output for list commands#3242arvindk-softwaredev wants to merge 1 commit into
Conversation
|
[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 |
801eef1 to
0149eb1
Compare
Add -o json and -o yaml support to list commands for pipelines, tasks, pipeline runs, task runs, event listeners, trigger bindings, cluster trigger bindings, trigger templates, and custom runs. Structured output is rendered as arrays of resource objects rather than Kubernetes List wrappers. Update help examples, generated docs, man pages, and add tests for structured, empty, invalid, and help output. Signed-off-by: Arvind <arvkrish@redhat.com> Assisted-by: Cursor Grok 4.6
0149eb1 to
bf00fb6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Structured serialization bypasses the advertised managed-fields filtering behavior.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds machine-readable JSON/YAML array output to nine Tekton resource list commands while retaining table output.
Changes:
- Adds shared structured-output and TypeMeta helpers.
- Integrates array output across Pipeline, Task, run, trigger, and CustomRun commands.
- Updates tests, golden files, command docs, and man pages.
File summaries
| File | Description |
|---|---|
test/e2e/pipeline/pipeline_test.go |
Validates Pipeline JSON arrays. |
pkg/formatted/output.go |
Adds structured-output helpers. |
pkg/formatted/output_test.go |
Tests shared helpers. |
pkg/cmd/triggertemplate/list.go |
Adds TriggerTemplate arrays. |
pkg/cmd/triggertemplate/list_test.go |
Tests TriggerTemplate output. |
pkg/cmd/triggerbinding/list.go |
Adds TriggerBinding arrays. |
pkg/cmd/triggerbinding/list_test.go |
Tests TriggerBinding output. |
pkg/cmd/taskrun/list.go |
Adds TaskRun arrays. |
pkg/cmd/taskrun/list_test.go |
Tests TaskRun output. |
pkg/cmd/task/testdata/TestTaskList_in_all_namespaces_with_output_yaml_flag.golden |
Updates Task YAML fixture. |
pkg/cmd/task/list.go |
Adds Task arrays and examples. |
pkg/cmd/task/list_test.go |
Tests Task output. |
pkg/cmd/pipelinerun/list.go |
Adds PipelineRun arrays. |
pkg/cmd/pipelinerun/list_test.go |
Tests PipelineRun output. |
pkg/cmd/pipeline/testdata/TestPipelineList_output_json.golden |
Adds Pipeline JSON fixture. |
pkg/cmd/pipeline/testdata/TestPipelineList_in_all_namespaces_with_output_yaml_flag.golden |
Updates Pipeline YAML fixture. |
pkg/cmd/pipeline/list.go |
Adds Pipeline arrays and examples. |
pkg/cmd/pipeline/list_test.go |
Tests Pipeline output. |
pkg/cmd/eventlistener/list.go |
Adds EventListener arrays. |
pkg/cmd/eventlistener/list_test.go |
Tests EventListener output. |
pkg/cmd/customrun/list.go |
Adds CustomRun arrays. |
pkg/cmd/customrun/list_test.go |
Tests CustomRun output. |
pkg/cmd/clustertriggerbinding/list.go |
Adds cluster binding arrays. |
pkg/cmd/clustertriggerbinding/list_test.go |
Tests cluster binding output. |
docs/man/man1/tkn-triggertemplate-list.1 |
Documents structured examples. |
docs/man/man1/tkn-triggerbinding-list.1 |
Documents structured examples. |
docs/man/man1/tkn-taskrun-list.1 |
Documents structured examples. |
docs/man/man1/tkn-task-list.1 |
Documents structured examples. |
docs/man/man1/tkn-pipelinerun-list.1 |
Documents structured examples. |
docs/man/man1/tkn-pipeline-list.1 |
Documents structured examples. |
docs/man/man1/tkn-eventlistener-list.1 |
Documents structured examples. |
docs/man/man1/tkn-customrun-list.1 |
Documents structured examples. |
docs/man/man1/tkn-clustertriggerbinding-list.1 |
Documents structured examples. |
docs/cmd/tkn_triggertemplate_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_triggerbinding_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_taskrun_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_task_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_pipelinerun_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_pipeline_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_eventlistener_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_customrun_list.md |
Adds JSON/YAML examples. |
docs/cmd/tkn_clustertriggerbinding_list.md |
Adds JSON/YAML examples. |
Review details
- Files reviewed: 42/42 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| func PrintStructuredOutput(w io.Writer, format string, obj interface{}) error { | ||
| switch NormalizeOutput(format) { | ||
| case OutputJSON: | ||
| data, err := json.MarshalIndent(obj, "", " ") |
Part of #2850
Changes
Adds
-o jsonand-o yamlto list commands so users can get machine-readable output instead of only the table view.Supported resources:
JSON/YAML is an array of resource objects, not a Kubernetes List wrapper. Each item includes canonical apiVersion and kind. Empty results print [] / []. Invalid formats are rejected with an error. Default table output is unchanged.
Shared helpers live in
pkg/formatted(PrintStructuredOutput,SetTypeMeta,IsStructured). Help text, generated docs, and man pages are updated. Unit tests cover structured output, empty lists, invalid formats, and help examples.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