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
|
# File 'lib/gitcycle/incident.rb', line 4
def incident(*args)
puts "\nRetrieving statuspage.io information from gitcycle.\n".green
statuspage = get('statuspage')
components = statuspage['components']
incidents = statuspage['incidents']
page = statuspage['page']
incident_statuses = %w(investigating identified monitoring resolved)
incident_colors = %w(red yellow yellow green)
component_statuses = %w(operational degraded_performance partial_outage major_outage)
component_colors = %w(green yellow yellow red)
puts_statuses(incidents, incident_statuses, incident_colors)
incident = q "\n#{"Incident #?".yellow} (press enter for new incident)"
if incident.strip == ""
incident = {}
new_incident = q "#{"New incident name?".yellow} (required)"
else
incident = incidents[incident.to_i]
end
unless incident['id'] || new_incident
puts "Incident not found."
exit
end
puts_names(incident_statuses, incident_colors)
incident_status = q "\n#{"Incident status #?".yellow} (required)"
incident_body = q "\n#{"Describe the incident".yellow} (enter for none)"
incident_status = incident_statuses[incident_status.to_i]
unless incident_status
puts "Incident status not found."
exit
end
puts_statuses(components, component_statuses, component_colors)
component = q "\n#{"Service #?".yellow} (required)"
component = components[component.to_i]
unless component
puts "Service not found."
exit
end
puts_names(component_statuses, component_colors)
component_status = q "\n#{"Service status #?".yellow} (required)"
component_status = component_statuses[component_status.to_i]
unless component_status
puts "Component status not found."
exit
end
params = {
:new_incident => new_incident,
:incident => incident['id'],
:component => component['id'],
:component_status => component_status,
:incident_status => incident_status,
:incident_body => incident_body
}
puts "\nUpdating statuspage.io...".green
get('statuspage/update', params)
puts "\nSuccess!\n".green
sleep 0.5
Launchy.open("http://#{page['subdomain']}.statuspage.io")
end
|