mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Handle offline scenarios for OpsGenie
This commit is contained in:
parent
204e3b4032
commit
aa658db210
30
config.yml
30
config.yml
@ -1,7 +1,7 @@
|
|||||||
wtf:
|
wtf:
|
||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
bamboohr:
|
bamboohr:
|
||||||
enabled: false
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 0
|
top: 0
|
||||||
left: 0
|
left: 0
|
||||||
@ -11,7 +11,7 @@ wtf:
|
|||||||
url: "https://api.bamboohr.com/api/gateway.php"
|
url: "https://api.bamboohr.com/api/gateway.php"
|
||||||
gcal:
|
gcal:
|
||||||
currentIcon: "💥"
|
currentIcon: "💥"
|
||||||
enabled: false
|
enabled: true
|
||||||
eventCount: 10
|
eventCount: 10
|
||||||
position:
|
position:
|
||||||
top: 2
|
top: 2
|
||||||
@ -22,7 +22,7 @@ wtf:
|
|||||||
secretFile: "~/.wtf/gcal/client_secret.json"
|
secretFile: "~/.wtf/gcal/client_secret.json"
|
||||||
git:
|
git:
|
||||||
commitCount: 5
|
commitCount: 5
|
||||||
enabled: false
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 0
|
top: 0
|
||||||
left: 2
|
left: 2
|
||||||
@ -31,7 +31,7 @@ wtf:
|
|||||||
refreshInterval: 8
|
refreshInterval: 8
|
||||||
repository: "/Users/chris/go/src/github.com/senorprogrammer/wtf"
|
repository: "/Users/chris/go/src/github.com/senorprogrammer/wtf"
|
||||||
github:
|
github:
|
||||||
enabled: false
|
enabled: true
|
||||||
organization: "BetterOfficeApps"
|
organization: "BetterOfficeApps"
|
||||||
position:
|
position:
|
||||||
top: 2
|
top: 2
|
||||||
@ -42,7 +42,7 @@ wtf:
|
|||||||
repo: "core-api"
|
repo: "core-api"
|
||||||
username: "senorprogrammer"
|
username: "senorprogrammer"
|
||||||
jira:
|
jira:
|
||||||
enabled: false
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 1
|
top: 1
|
||||||
left: 1
|
left: 1
|
||||||
@ -51,16 +51,16 @@ wtf:
|
|||||||
refreshInterval: 900
|
refreshInterval: 900
|
||||||
newrelic:
|
newrelic:
|
||||||
applicationId: 10549735
|
applicationId: 10549735
|
||||||
enabled: false
|
enabled: true
|
||||||
deployCount: 7
|
deployCount: 10
|
||||||
position:
|
position:
|
||||||
top: 4
|
top: 4
|
||||||
left: 2
|
left: 2
|
||||||
height: 1
|
height: 2
|
||||||
width: 3
|
width: 3
|
||||||
refreshInterval: 900
|
refreshInterval: 900
|
||||||
opsgenie:
|
opsgenie:
|
||||||
enabled: false
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 2
|
top: 2
|
||||||
left: 0
|
left: 0
|
||||||
@ -68,20 +68,20 @@ wtf:
|
|||||||
width: 1
|
width: 1
|
||||||
refreshInterval: 21600
|
refreshInterval: 21600
|
||||||
security:
|
security:
|
||||||
enabled: false
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 5
|
top: 4
|
||||||
left: 0
|
left: 0
|
||||||
height: 1
|
height: 1
|
||||||
width: 1
|
width: 1
|
||||||
refreshInterval: 3600
|
refreshInterval: 3600
|
||||||
status:
|
status:
|
||||||
enabled: false
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 5
|
top: 5
|
||||||
left: 2
|
left: 0
|
||||||
height: 3
|
height: 1
|
||||||
width: 3
|
width: 1
|
||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
weather:
|
weather:
|
||||||
cityId: 6173331
|
cityId: 6173331
|
||||||
|
@ -69,10 +69,9 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
|
|||||||
for _, deploy := range deploys {
|
for _, deploy := range deploys {
|
||||||
if (deploy.Revision != "") && wtf.Exclude(revisions, deploy.Revision) {
|
if (deploy.Revision != "") && wtf.Exclude(revisions, deploy.Revision) {
|
||||||
str = str + fmt.Sprintf(
|
str = str + fmt.Sprintf(
|
||||||
" %03d [green]%s[white] %-6s %s\n",
|
" [green]%s[white] %s %-16s\n",
|
||||||
deploy.ID%1000,
|
|
||||||
deploy.Revision[0:8],
|
deploy.Revision[0:8],
|
||||||
deploy.Timestamp.Format("Jan 2"),
|
deploy.Timestamp.Format("Jan 02, 15:04"),
|
||||||
wtf.NameFromEmail(deploy.User),
|
wtf.NameFromEmail(deploy.User),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,22 +27,21 @@ type Parent struct {
|
|||||||
|
|
||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
func Fetch() *OnCallResponse {
|
func Fetch() (*OnCallResponse, error) {
|
||||||
apiKey := os.Getenv("WTF_OPS_GENIE_API_KEY")
|
apiKey := os.Getenv("WTF_OPS_GENIE_API_KEY")
|
||||||
scheduleUrl := "https://api.opsgenie.com/v2/schedules/on-calls?flat=true"
|
scheduleUrl := "https://api.opsgenie.com/v2/schedules/on-calls?flat=true"
|
||||||
|
|
||||||
var onCallResponse OnCallResponse
|
response, err := opsGenieRequest(scheduleUrl, apiKey)
|
||||||
opsGenieRequest(scheduleUrl, apiKey, &onCallResponse)
|
|
||||||
|
|
||||||
return &onCallResponse
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func opsGenieRequest(url string, apiKey string, payload interface{}) {
|
func opsGenieRequest(url string, apiKey string) (*OnCallResponse, error) {
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("Authorization", fmt.Sprintf("GenieKey %s", apiKey))
|
req.Header.Set("Authorization", fmt.Sprintf("GenieKey %s", apiKey))
|
||||||
@ -51,11 +50,14 @@ func opsGenieRequest(url string, apiKey string, payload interface{}) {
|
|||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if err := json.NewDecoder(resp.Body).Decode(payload); err != nil {
|
response := &OnCallResponse{}
|
||||||
panic(err)
|
if err := json.NewDecoder(resp.Body).Decode(response); err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response, nil
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,20 @@ func (widget *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data := Fetch()
|
data, err := Fetch()
|
||||||
|
|
||||||
widget.View.SetTitle(" ⏰ On Call ")
|
widget.View.SetTitle(" ⏰ On Call ")
|
||||||
widget.RefreshedAt = time.Now()
|
widget.RefreshedAt = time.Now()
|
||||||
|
|
||||||
widget.View.Clear()
|
widget.View.Clear()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
widget.View.SetWrap(true)
|
||||||
|
fmt.Fprintf(widget.View, "%s", err)
|
||||||
|
} else {
|
||||||
|
widget.View.SetWrap(false)
|
||||||
fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
|
fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -58,8 +58,14 @@ func (widget *Widget) addView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(data map[string]string) string {
|
func (widget *Widget) contentFrom(data map[string]string) string {
|
||||||
str := fmt.Sprintf(" Firewall: %s Network: %s\n", data["Enabled"], data["Network"])
|
str := " [red]WiFi[white]\n"
|
||||||
str = str + fmt.Sprintf(" Stealth: %s Crypto: %s\n", data["Stealth"], data["Encryption"])
|
str = str + fmt.Sprintf(" %8s: %s\n", "Network", data["Network"])
|
||||||
|
str = str + fmt.Sprintf(" %8s: %s\n", "Crypto", data["Encryption"])
|
||||||
|
str = str + "\n"
|
||||||
|
str = str + " [red]Firewall[white]\n"
|
||||||
|
str = str + fmt.Sprintf(" %8s: %s\n", "Enabled", data["Enabled"])
|
||||||
|
str = str + fmt.Sprintf(" %8s: %s\n", "Stealth", data["Stealth"])
|
||||||
|
str = str + "\n"
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
data := Fetch(Config.UInt("wtf.weather.cityId", 6176823))
|
data := Fetch(Config.UInt("wtf.weather.cityId", 6176823))
|
||||||
|
|
||||||
widget.View.SetTitle(fmt.Sprintf(" %s Weather - %s ", icon(data), data.Name))
|
widget.View.SetTitle(fmt.Sprintf(" %s Weather: [green]%s[white] ", icon(data), data.Name))
|
||||||
widget.RefreshedAt = time.Now()
|
widget.RefreshedAt = time.Now()
|
||||||
|
|
||||||
widget.View.Clear()
|
widget.View.Clear()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user