Skip to content

Commit

Permalink
add check in pr logs for if condition available
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhelfand authored and tekton-robot committed Nov 21, 2019
1 parent 8abfc07 commit d382739
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/cmd/pipelinerun/log_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()

Expand Down Expand Up @@ -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)
}
}()
Expand Down Expand Up @@ -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
}

0 comments on commit d382739

Please sign in to comment.