diff --git a/docs/cmd/tkn_pipelinerun_logs.md b/docs/cmd/tkn_pipelinerun_logs.md index 681994119c..1648dc4d0e 100644 --- a/docs/cmd/tkn_pipelinerun_logs.md +++ b/docs/cmd/tkn_pipelinerun_logs.md @@ -31,7 +31,6 @@ Show the logs of PipelineRun named 'microservice-1' for all Tasks and steps (inc ``` -a, --all show all logs including init steps injected by tekton - --display-name show logs with task display name (display name and step name) -E, --exit-with-pipelinerun-error exit with pipelinerun to the unix shell, 0 if success, 1 if error, 2 on unknown status -f, --follow stream live logs -F, --fzf use fzf to select a PipelineRun diff --git a/docs/man/man1/tkn-pipelinerun-logs.1 b/docs/man/man1/tkn-pipelinerun-logs.1 index 0da46f67bd..a5879ea6d8 100644 --- a/docs/man/man1/tkn-pipelinerun-logs.1 +++ b/docs/man/man1/tkn-pipelinerun-logs.1 @@ -23,10 +23,6 @@ Show the logs of a PipelineRun \fB\-a\fP, \fB\-\-all\fP[=false] show all logs including init steps injected by tekton -.PP -\fB\-\-display\-name\fP[=false] - show logs with task display name (display name and step name) - .PP \fB\-E\fP, \fB\-\-exit\-with\-pipelinerun\-error\fP[=false] exit with pipelinerun to the unix shell, 0 if success, 1 if error, 2 on unknown status diff --git a/pkg/cmd/pipelinerun/logs.go b/pkg/cmd/pipelinerun/logs.go index ecfae7efeb..235003cfcb 100644 --- a/pkg/cmd/pipelinerun/logs.go +++ b/pkg/cmd/pipelinerun/logs.go @@ -84,7 +84,6 @@ Show the logs of PipelineRun named 'microservice-1' for all Tasks and steps (inc c.Flags().BoolVarP(&opts.Follow, "follow", "f", false, "stream live logs") c.Flags().BoolVarP(&opts.Timestamps, "timestamps", "", false, "show logs with timestamp") c.Flags().BoolVarP(&opts.Prefixing, "prefix", "", true, "prefix each log line with the log source (task name and step name)") - c.Flags().BoolVarP(&opts.DisplayName, "display-name", "", false, "show logs with task display name (display name and step name)") c.Flags().BoolVarP(&opts.ExitWithPrError, "exit-with-pipelinerun-error", "E", false, "exit with pipelinerun to the unix shell, 0 if success, 1 if error, 2 on unknown status") c.Flags().StringSliceVarP(&opts.Tasks, "task", "t", []string{}, "show logs for mentioned Tasks only") c.Flags().IntVarP(&opts.Limit, "limit", "", defaultLimit, "lists number of PipelineRuns") @@ -111,7 +110,7 @@ func Run(opts *options.LogOptions) error { return err } - log.NewWriter(log.LogTypePipeline, opts.Prefixing).WithDisplayName(opts.DisplayName).Write(opts.Stream, logC, errC) + log.NewWriter(log.LogTypePipeline, opts.Prefixing).Write(opts.Stream, logC, errC) // get pipelinerun status if opts.ExitWithPrError { diff --git a/pkg/log/log.go b/pkg/log/log.go index c95a6f93f4..7e1f606b71 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -27,9 +27,8 @@ var pipelineGroupResource = schema.GroupVersionResource{Group: "tekton.dev", Res // Log represents data to write on log channel type Log struct { - Pipeline string - Task string - TaskDisplayName string - Step string - Log string + Pipeline string + Task string + Step string + Log string } diff --git a/pkg/log/pipeline_reader.go b/pkg/log/pipeline_reader.go index 19cb59312b..740d416ce9 100644 --- a/pkg/log/pipeline_reader.go +++ b/pkg/log/pipeline_reader.go @@ -192,7 +192,7 @@ func (r *Reader) pipeLogs(logC chan<- Log, errC chan<- error) { tlogC = nil continue } - logC <- Log{Task: l.Task, TaskDisplayName: l.TaskDisplayName, Step: l.Step, Log: l.Log} + logC <- Log{Task: l.Task, Step: l.Step, Log: l.Log} case e, ok := <-terrC: if !ok { @@ -208,7 +208,6 @@ func (r *Reader) setUpTask(taskNumber int, tr taskrunpkg.Run) { r.setNumber(taskNumber) r.setRun(tr.Name) r.setTask(tr.Task) - r.setDisplayName(tr.DisplayName) r.setRetries(tr.Retries) } diff --git a/pkg/log/reader.go b/pkg/log/reader.go index 2ebe019e64..e4ded0d591 100644 --- a/pkg/log/reader.go +++ b/pkg/log/reader.go @@ -37,7 +37,6 @@ type Reader struct { steps []string logType string task string - displayName string number int activityTimeout time.Duration retries int @@ -109,10 +108,6 @@ func (r *Reader) setTask(task string) { r.task = task } -func (r *Reader) setDisplayName(displayName string) { - r.displayName = displayName -} - func (r *Reader) clone() *Reader { c := *r return &c diff --git a/pkg/log/task_reader.go b/pkg/log/task_reader.go index ecb80da0a6..7ba470bb2a 100644 --- a/pkg/log/task_reader.go +++ b/pkg/log/task_reader.go @@ -138,10 +138,10 @@ func (r *Reader) readStepsLogs(logC chan<- Log, errC chan<- error, steps []*step case l, ok := <-containerLogC: if !ok { containerLogC = nil - logC <- Log{Task: r.task, TaskDisplayName: r.displayName, Step: step.name, Log: "EOFLOG"} + logC <- Log{Task: r.task, Step: step.name, Log: "EOFLOG"} continue } - logC <- Log{Task: r.task, TaskDisplayName: r.displayName, Step: step.name, Log: l.Log} + logC <- Log{Task: r.task, Step: step.name, Log: l.Log} case e, ok := <-containerLogErrC: if !ok { diff --git a/pkg/log/writer.go b/pkg/log/writer.go index 074ec33560..0e965987ba 100644 --- a/pkg/log/writer.go +++ b/pkg/log/writer.go @@ -23,10 +23,9 @@ import ( // Writer helps logging pod"s log type Writer struct { - fmt *formatted.Color - logType string - prefixing bool - displayName bool + fmt *formatted.Color + logType string + prefixing bool } // NewWriter returns the new instance of LogWriter @@ -38,12 +37,6 @@ func NewWriter(logType string, prefixing bool) *Writer { } } -// WithDisplayName sets the display name -func (lw *Writer) WithDisplayName(displayName bool) *Writer { - lw.displayName = displayName - return lw -} - // Write formatted pod's logs func (lw *Writer) Write(s *cli.Stream, logC <-chan Log, errC <-chan error) { for logC != nil || errC != nil { @@ -59,10 +52,6 @@ func (lw *Writer) Write(s *cli.Stream, logC <-chan Log, errC <-chan error) { continue } - if lw.displayName && l.TaskDisplayName != "" { - l.Task = l.TaskDisplayName - } - if lw.prefixing { switch lw.logType { case LogTypePipeline: diff --git a/pkg/options/logs.go b/pkg/options/logs.go index 8fe588f55f..8e353570b6 100644 --- a/pkg/options/logs.go +++ b/pkg/options/logs.go @@ -51,7 +51,6 @@ type LogOptions struct { Tail int64 Timestamps bool Prefixing bool - DisplayName bool ExitWithPrError bool // ActivityTimeout is the amount of time to wait for some activity // (e.g. Pod ready) before giving up. diff --git a/pkg/taskrun/taskrun.go b/pkg/taskrun/taskrun.go index 64d314c5cf..f748d5df61 100644 --- a/pkg/taskrun/taskrun.go +++ b/pkg/taskrun/taskrun.go @@ -23,7 +23,6 @@ import ( type Run struct { Name string - DisplayName string Task string Retries int StartTime *metav1.Time @@ -91,9 +90,8 @@ func SortTasksBySpecOrder(pipelineTasks []v1.PipelineTask, pipelinesTaskRuns map if n, ok := trNames[ts.Name]; ok { trStatusFields := pipelinesTaskRuns[n].Status.TaskRunStatusFields trs = append(trs, Run{ - Task: ts.Name, + Task: taskName(ts), Name: n, - DisplayName: ts.DisplayName, Retries: ts.Retries, StartTime: trStatusFields.StartTime, CompletionTime: trStatusFields.CompletionTime, @@ -103,3 +101,10 @@ func SortTasksBySpecOrder(pipelineTasks []v1.PipelineTask, pipelinesTaskRuns map sort.Sort(trs) return trs } + +func taskName(task v1.PipelineTask) string { + if task.DisplayName != "" { + return task.DisplayName + } + return task.Name +}