OLD | NEW |
| (Empty) |
1 // Copyright 2017 The LUCI Authors. All rights reserved. | |
2 // Use of this source code is governed under the Apache License, Version 2.0 | |
3 // that can be found in the LICENSE file. | |
4 | |
5 //go:generate stringer -type=Status | |
6 | |
7 package model | |
8 | |
9 import "encoding/json" | |
10 | |
11 // Status is a discrete status for the purpose of colorizing a component. | |
12 // These are based off the Material Design Bootstrap color palettes. | |
13 type Status int | |
14 | |
15 const ( | |
16 // NotRun if the component has not yet been run. | |
17 NotRun Status = iota // 100 Gray | |
18 | |
19 // Running if the component is currently running. | |
20 Running // 100 Teal | |
21 | |
22 // Success if the component has finished executing and is not noteworthy
. | |
23 Success // A200 Green | |
24 | |
25 // Failure if the component has finished executing and contains a failur
e. | |
26 Failure // A200 Red | |
27 | |
28 // Warning just like from the buildbot days. | |
29 Warning // 200 Yellow | |
30 | |
31 // InfraFailure if the component has finished incompletely due to a fail
ure in infra. | |
32 InfraFailure // A100 Purple | |
33 | |
34 // Exception if the component has finished incompletely and unexpectedly
. This | |
35 // is used for buildbot builds. | |
36 Exception // A100 Purple | |
37 | |
38 // Expired if the component was never scheduled due to resource exhausti
on. | |
39 Expired // A200 Purple | |
40 | |
41 // DependencyFailure if the component has finished incompletely due to a
failure in a | |
42 // dependency. | |
43 DependencyFailure // 100 Amber | |
44 | |
45 // WaitingDependency if the component has finished or paused execution d
ue to an | |
46 // incomplete dep. | |
47 WaitingDependency // 100 Brown | |
48 ) | |
49 | |
50 // Terminal returns true if the step status won't change. | |
51 func (s Status) Terminal() bool { | |
52 switch s { | |
53 case Success, Failure, InfraFailure, Warning, DependencyFailure, Expired
: | |
54 return true | |
55 default: | |
56 return false | |
57 } | |
58 } | |
59 | |
60 // MarshalJSON renders enums into String rather than an int when marshalling. | |
61 func (s Status) MarshalJSON() ([]byte, error) { | |
62 return json.Marshal(s.String()) | |
63 } | |
OLD | NEW |