Repository navigation
Conversation
Signed-off-by: Debashich <debashishsinha555@gmail.com>
Signed-off-by: Debashich <debashishsinha555@gmail.com>
|
[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 |
|
Hey @divyansh42! Got this ready for review. Whenever you get some time PTAL |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues drop requested timestamps from text logs, contaminate JSON output with plain-text diagnostics, and can cause a panic on null termination-message entries.
3 open issues
What changed in this PR
Adds structured log output to tkn pipelinerun logs and tkn taskrun logs for agents and automated tools, using the shared log-reading and formatting infrastructure.
Changes:
- Adds
-o/--output jsonfor newline-delimited JSON, including follow mode. - Carries Kubernetes timestamps into structured records with task, step, and message fields.
- Updates command references and man pages; human-readable output remains the default.
| File | Description |
|---|---|
pkg/pods/container.go |
Extracts timestamps from Kubernetes log lines. |
pkg/options/logs.go |
Adds the output-format option. |
pkg/log/writer.go |
Encodes structured log records as NDJSON. |
pkg/log/task_reader.go |
Forwards timestamps and changes termination-result decoding. |
pkg/log/pipeline_reader.go |
Forwards timestamps through pipeline logs. |
pkg/log/log.go |
Adds timestamps to shared log records. |
pkg/cmd/taskrun/logs.go |
Exposes and configures JSON output for TaskRun logs. |
pkg/cmd/pipelinerun/logs.go |
Exposes and configures JSON output for PipelineRun logs. |
docs/man/man1/tkn-taskrun-logs.1 |
Documents the TaskRun output flag. |
docs/man/man1/tkn-pipelinerun-logs.1 |
Documents the PipelineRun output flag. |
docs/cmd/tkn_taskrun_logs.md |
Updates the TaskRun command reference. |
docs/cmd/tkn_pipelinerun_logs.md |
Updates the PipelineRun command reference. |
Review effort: Balanced
| if opts.Output == "json" { | ||
| opts.Timestamps = true | ||
| opts.Prefixing = false | ||
| } | ||
|
|
||
| lr, err := log.NewReader(log.LogTypePipeline, opts) |
| // a real failure is a "Skipped" reason in the termination message. | ||
| func isSkippedStep(term *corev1.ContainerStateTerminated) bool { | ||
| var results []result.RunResult | ||
| var results []*result.RunResult |
| lw.fmt.Rainbow.Fprintf(l.Step, s.Out, "[%s] ", l.Step) | ||
| } | ||
| } | ||
| fmt.Fprintf(s.Out, "%s\n", l.Log) |

Changes
Add JSON output support to
tkn pipelinerun logsandtkn taskrun logs, making log output easier for agents and automated tools to consume.-o/--outputflag to both commands.--follow.Closes #2854
Submitter Checklist
make check(no lint issues in this PR; remaining findings are pre-existing and unrelated)make generatedSee [the contribution guide](https://github.com/tektoncd/cli/blob/master/CONTRIBUTING.md) for more details.
Release Notes