-
Notifications
You must be signed in to change notification settings - Fork 13
/
shields.go
86 lines (73 loc) · 1.92 KB
/
shields.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
// Endpoint specifies the shields.io expected endpoint response
//
// Documentation: https://shields.io/endpoint
type Endpoint struct {
SchemaVersion int `json:"schemaVersion,omitempty"`
Label string `json:"label,omitempty"`
Message string `json:"message,omitempty"`
Color string `json:"color,omitempty"`
LabelColor string `json:"labelColor,omitempty"`
IsError bool `json:"isError,omitempty"`
NamedLogo string `json:"namedLogo,omitempty"`
LogoSVG string `json:"logoSvg,omitempty"`
LogoColor string `json:"logoColor,omitempty"`
LogoWidth int `json:"logoWidth,omitempty"`
LogoPosition string `json:"logoPosition,omitempty"`
Style string `json:"style,omitempty"`
CacheSeconds int `json:"cacheSeconds,omitempty"`
}
// NewEndpoint instantiates a new endpoint instance with default values
func NewEndpoint() *Endpoint {
return &Endpoint{
SchemaVersion: 1,
CacheSeconds: 300,
Label: "GitHub Actions",
NamedLogo: "github",
}
}
func (e *Endpoint) Success() {
e.Color = "success"
e.Message = "success"
}
func (e *Endpoint) Neutral() {
e.Color = "success"
e.Message = "neutral"
}
func (e *Endpoint) Pending() {
e.Color = "yellow"
e.Message = "pending"
}
func (e *Endpoint) Failure() {
e.Color = "critical"
e.Message = "failure"
}
func (e *Endpoint) Cancelled() {
e.Color = "inactive"
e.Message = "cancelled"
}
func (e *Endpoint) TimedOut() {
e.Color = "critical"
e.Message = "timed out"
e.IsError = true
}
func (e *Endpoint) ActionRequired() {
e.Color = "critical"
e.Message = "action required"
e.IsError = true
}
func (e *Endpoint) ServerError() {
e.Color = "inactive"
e.Message = "server error"
e.IsError = true
}
func (e *Endpoint) NoRuns() {
e.Color = "inactive"
e.Message = "no runs"
e.IsError = true
}
func (e *Endpoint) RepositoryNotFound() {
e.Color = "critical"
e.Message = "repository not found"
e.IsError = true
}