Repository navigation
Expand file tree
/
Copy pathtypes.go
More file actions
200 lines (176 loc) · 5.89 KB
/
Copy pathtypes.go
File metadata and controls
200 lines (176 loc) · 5.89 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package githubstatus
import (
"fmt"
)
// Indicator is the overall ("rollup") status of GitHub as reported by
// githubstatus.com.
//
// Values that are not recognised are preserved as-is and have a severity of
// zero, so new values introduced by the API will not break decoding.
type Indicator string
const (
// IndicatorNone means all monitored systems are operational.
IndicatorNone Indicator = "none"
// IndicatorMinor means a minor service issue is affecting GitHub.
IndicatorMinor Indicator = "minor"
// IndicatorMajor means a major service issue is affecting GitHub.
IndicatorMajor Indicator = "major"
// IndicatorCritical means a critical service issue is affecting GitHub.
IndicatorCritical Indicator = "critical"
// IndicatorMaintenance means planned maintenance is in progress.
IndicatorMaintenance Indicator = "maintenance"
)
// Severity returns an ordinal for comparing indicators.
//
// "none", "maintenance" and unknown values are all 0; use IsMaintenance to
// detect planned maintenance separately.
func (i Indicator) Severity() int {
switch i {
case IndicatorMinor:
return 1
case IndicatorMajor:
return 2
case IndicatorCritical:
return 3
default:
return 0
}
}
// IsMaintenance reports whether the indicator signals planned maintenance.
func (i Indicator) IsMaintenance() bool {
return i == IndicatorMaintenance
}
// ParseIndicator parses a threshold value such as "major".
// Only values with a non-zero severity are accepted.
func ParseIndicator(s string) (Indicator, error) {
i := Indicator(s)
if i.Severity() == 0 {
return "", &ParseError{Kind: "indicator", Value: s}
}
return i, nil
}
// ComponentStatus is the status of a single GitHub component.
type ComponentStatus string
const (
// Operational means a component is functioning normally.
Operational ComponentStatus = "operational"
// DegradedPerformance means a component is slower or less reliable than usual.
DegradedPerformance ComponentStatus = "degraded_performance"
// PartialOutage means a component is partially unavailable.
PartialOutage ComponentStatus = "partial_outage"
// MajorOutage means a component is unavailable to most users.
MajorOutage ComponentStatus = "major_outage"
// UnderMaintenance means planned maintenance is in progress for a component.
UnderMaintenance ComponentStatus = "under_maintenance"
)
// Severity returns an ordinal for comparing component statuses.
//
// "operational", "under_maintenance" and unknown values are all 0; use
// IsMaintenance to detect planned maintenance separately.
func (c ComponentStatus) Severity() int {
switch c {
case DegradedPerformance:
return 1
case PartialOutage:
return 2
case MajorOutage:
return 3
default:
return 0
}
}
// IsMaintenance reports whether the component is under planned maintenance.
func (c ComponentStatus) IsMaintenance() bool {
return c == UnderMaintenance
}
// ParseComponentStatus parses a threshold value such as "partial_outage".
// Only values with a non-zero severity are accepted.
func ParseComponentStatus(s string) (ComponentStatus, error) {
c := ComponentStatus(s)
if c.Severity() == 0 {
return "", &ParseError{Kind: "component status", Value: s}
}
return c, nil
}
// ParseError is returned when a threshold value cannot be parsed, or when
// Thresholds.Validate finds a threshold that can never be exceeded.
type ParseError struct {
// Kind is "indicator" or "component status".
Kind string
// Value is the rejected value.
Value string
// Component is the component the threshold was configured for, if any.
Component string
}
func (e *ParseError) Error() string {
msg := fmt.Sprintf("githubstatus: invalid %s threshold %q", e.Kind, e.Value)
if e.Component != "" {
msg += fmt.Sprintf(" for component %q", e.Component)
}
return msg
}
// IncidentStatus is the status of an incident, scheduled maintenance or
// incident update.
type IncidentStatus string
// Statuses used by incidents.
const (
IncidentInvestigating IncidentStatus = "investigating"
IncidentIdentified IncidentStatus = "identified"
IncidentMonitoring IncidentStatus = "monitoring"
IncidentResolved IncidentStatus = "resolved"
IncidentPostmortem IncidentStatus = "postmortem"
)
// Statuses used by scheduled maintenances.
const (
MaintenanceScheduled IncidentStatus = "scheduled"
MaintenanceInProgress IncidentStatus = "in_progress"
MaintenanceVerifying IncidentStatus = "verifying"
MaintenanceCompleted IncidentStatus = "completed"
)
// Impact is the impact of an incident or scheduled maintenance.
type Impact string
const (
// ImpactNone means the incident has no user-facing impact.
ImpactNone Impact = "none"
// ImpactMinor means the incident has a limited user-facing impact.
ImpactMinor Impact = "minor"
// ImpactMajor means the incident has a significant user-facing impact.
ImpactMajor Impact = "major"
// ImpactCritical means the incident has a critical user-facing impact.
ImpactCritical Impact = "critical"
// ImpactMaintenance means the incident represents planned maintenance.
ImpactMaintenance Impact = "maintenance"
)
// Severity returns an ordinal for comparing impacts.
//
// "none", "maintenance" and unknown values are all 0; use IsMaintenance to
// detect planned maintenance separately.
func (i Impact) Severity() int {
switch i {
case ImpactMinor:
return 1
case ImpactMajor:
return 2
case ImpactCritical:
return 3
default:
return 0
}
}
// IsMaintenance reports whether the impact signals planned maintenance.
func (i Impact) IsMaintenance() bool {
return i == ImpactMaintenance
}
// Well-known GitHub component names, as they appear in the API.
const (
ComponentGit = "Git Operations"
ComponentAPI = "API Requests"
ComponentWebhooks = "Webhooks"
ComponentIssues = "Issues"
ComponentPullRequests = "Pull Requests"
ComponentActions = "Actions"
ComponentPackages = "Packages"
ComponentPages = "Pages"
ComponentCodespaces = "Codespaces"
ComponentCopilot = "Copilot"
)