From 8cee3eb4b7d071eeea7827e27ff926645e9887bb Mon Sep 17 00:00:00 2001 From: Daniel Helfand Date: Mon, 18 Nov 2019 15:01:32 -0500 Subject: [PATCH] add check in pr logs for if condition available --- pkg/cmd/pipelinerun/log_reader.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/pipelinerun/log_reader.go b/pkg/cmd/pipelinerun/log_reader.go index 2f62021dc..d3a7293ca 100644 --- a/pkg/cmd/pipelinerun/log_reader.go +++ b/pkg/cmd/pipelinerun/log_reader.go @@ -95,10 +95,8 @@ func (lr *LogReader) readLiveLogs(pr *v1alpha1.PipelineRun) (<-chan Log, <-chan wg.Wait() - if pr.Status.Conditions != nil { - if pr.Status.Conditions[0].Status == corev1.ConditionFalse { - errC <- fmt.Errorf(pr.Status.Conditions[0].Message) - } + if !empty(pr.Status) && pr.Status.Conditions[0].Status == corev1.ConditionFalse { + errC <- fmt.Errorf(pr.Status.Conditions[0].Message) } }() @@ -134,7 +132,8 @@ func (lr *LogReader) readAvailableLogs(pr *v1alpha1.PipelineRun) (<-chan Log, <- pipeLogs(logC, errC, tlr) } - if pr.Status.Conditions[0].Status == corev1.ConditionFalse { + + if !empty(pr.Status) && pr.Status.Conditions[0].Status == corev1.ConditionFalse { errC <- fmt.Errorf(pr.Status.Conditions[0].Message) } }() @@ -213,5 +212,10 @@ func pipeLogs(logC chan<- Log, errC chan<- error, tlr *taskrun.LogReader) { } func empty(status v1alpha1.PipelineRunStatus) bool { + + if status.Conditions == nil { + return true + } + return len(status.Conditions) == 0 }