| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package logdog | 5 package logdog |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "time" | 9 "time" |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 case miloProto.Status_SUCCESS: | 43 case miloProto.Status_SUCCESS: |
| 44 comp.Status = resp.Success | 44 comp.Status = resp.Success |
| 45 | 45 |
| 46 case miloProto.Status_FAILURE: | 46 case miloProto.Status_FAILURE: |
| 47 if fd := anno.GetFailureDetails(); fd != nil { | 47 if fd := anno.GetFailureDetails(); fd != nil { |
| 48 switch fd.Type { | 48 switch fd.Type { |
| 49 case miloProto.FailureDetails_EXCEPTION, miloProto.Failu
reDetails_INFRA: | 49 case miloProto.FailureDetails_EXCEPTION, miloProto.Failu
reDetails_INFRA: |
| 50 comp.Status = resp.InfraFailure | 50 comp.Status = resp.InfraFailure |
| 51 | 51 |
| 52 case miloProto.FailureDetails_EXPIRED: |
| 53 comp.Status = resp.Expired |
| 54 |
| 52 case miloProto.FailureDetails_DM_DEPENDENCY_FAILED: | 55 case miloProto.FailureDetails_DM_DEPENDENCY_FAILED: |
| 53 comp.Status = resp.DependencyFailure | 56 comp.Status = resp.DependencyFailure |
| 54 | 57 |
| 55 default: | 58 default: |
| 56 comp.Status = resp.Failure | 59 comp.Status = resp.Failure |
| 57 } | 60 } |
| 58 | 61 |
| 59 if fd.Text != "" { | 62 if fd.Text != "" { |
| 60 comp.Text = append(comp.Text, fd.Text) | 63 comp.Text = append(comp.Text, fd.Text) |
| 61 } | 64 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 143 } |
| 141 | 144 |
| 142 // This should be the exact same thing. | 145 // This should be the exact same thing. |
| 143 comp.Text = append(comp.Text, anno.Text...) | 146 comp.Text = append(comp.Text, anno.Text...) |
| 144 | 147 |
| 145 return comp | 148 return comp |
| 146 } | 149 } |
| 147 | 150 |
| 148 // AddLogDogToBuild takes a set of logdog streams and populate a milo build. | 151 // AddLogDogToBuild takes a set of logdog streams and populate a milo build. |
| 149 // build.Summary.Finished must be set. | 152 // build.Summary.Finished must be set. |
| 150 func AddLogDogToBuild(c context.Context, ub URLBuilder, s *Streams, build *resp.
MiloBuild) { | 153 func AddLogDogToBuild( |
| 151 » if s.MainStream == nil { | 154 » c context.Context, ub URLBuilder, mainAnno *miloProto.Step, build *resp.
MiloBuild) { |
| 152 » » panic("missing main stream") | 155 » now := clock.Now(c) |
| 153 » } | |
| 154 » // Now Fetch the main annotation of the build. | |
| 155 » var ( | |
| 156 » » mainAnno = s.MainStream.Data | |
| 157 » » now = clock.Now(c) | |
| 158 » ) | |
| 159 | 156 |
| 160 // Now fill in each of the step components. | 157 // Now fill in each of the step components. |
| 161 // TODO(hinoka): This is totes cachable. | 158 // TODO(hinoka): This is totes cachable. |
| 162 buildCompletedTime := mainAnno.Ended.Time() | 159 buildCompletedTime := mainAnno.Ended.Time() |
| 163 build.Summary = *(miloBuildStep(ub, mainAnno, buildCompletedTime, now)) | 160 build.Summary = *(miloBuildStep(ub, mainAnno, buildCompletedTime, now)) |
| 164 for _, substepContainer := range mainAnno.Substep { | 161 for _, substepContainer := range mainAnno.Substep { |
| 165 anno := substepContainer.GetStep() | 162 anno := substepContainer.GetStep() |
| 166 if anno == nil { | 163 if anno == nil { |
| 167 // TODO: We ignore non-embedded substeps for now. | 164 // TODO: We ignore non-embedded substeps for now. |
| 168 continue | 165 continue |
| (...skipping 20 matching lines...) Expand all Loading... |
| 189 for _, prop := range mainAnno.Property { | 186 for _, prop := range mainAnno.Property { |
| 190 propGroup.Property = append(propGroup.Property, &resp.Property{ | 187 propGroup.Property = append(propGroup.Property, &resp.Property{ |
| 191 Key: prop.Name, | 188 Key: prop.Name, |
| 192 Value: prop.Value, | 189 Value: prop.Value, |
| 193 }) | 190 }) |
| 194 } | 191 } |
| 195 build.PropertyGroup = append(build.PropertyGroup, propGroup) | 192 build.PropertyGroup = append(build.PropertyGroup, propGroup) |
| 196 | 193 |
| 197 return | 194 return |
| 198 } | 195 } |
| OLD | NEW |