PagerDuty OncallStatus for MacOS

Mike Tougeron
GrepMyMind
Published in
5 min readAug 16, 2021

I’m now happy to introduce the new open source application OncallStatus for PagerDuty on MacOS!

drawing of an old school pager

Being oncall is never fun and rarely easy. On top of that it can also be _noisy_. The phone alerts are always loud as they try to get your attention. Beyond that, when I’m already at the computer the noise from my phone bothers me immensely. Pre-covid when I was in the office it would disturb my teammates and while working from home it creates excess stress that I don’t need. I’d rather have my computer notify me instead. Rather than complain and do nothing, I still bitched but did something about it.

The OncallStatus app was my solution to this problem. This new app works with your PagerDuty oncall schedules and notifies you when a new incident has been created.

example notification

You can filter the events based on high & low priority or the escalation level you are assigned to. No need to get that extra visual noise for the low priority stuff. Now I can set my phone to silent when I’m at my desk and the noise is much easier on my mind.

Written in Go

As I’ve been learning/working with Go lately I decided to try and use that to write this app. Using the cgo bindings it is possible to call Cocoa functions and have native MacOS functionality built into your Go app. I started with using a nice library called menuet but unfortunately it hasn’t been kept up-to-date and had a tendency to crash a lot on startup. Looking for another library that could do menu bar updates I came across getlantern/systray. While not as feature rich as menuet, it worked AND it promised cross-platform compatibility. While I haven’t been able to work on the Linux & Windows support yet, I’m happy that it should be possible.

Shows the menu options for the application

Unfortunately when it came to notifications the only cross-platform library I could find was severely lacking in functionality. So in the spirit of an MVP I decided to stick with just MacOS to start. I took a bit of code from menuet and some from a utility called go-notifier. This allowed me to create a notification that was clickable and would open a web browser straight to the incident page. Because most of this code was Cocoa it took me _a long time_ to get it working. It’s not the greatest code but it does get the job done. I know I’m going to have to go back and refactor it at some point.

A neat idea that I learned from menuet is checking GitHub for new releases of OncallStatus. When the tag used for the current running version doesn’t match the latest release on GitHub it creates a notification letting you know there is a new version. This could be done with just a few lines of code thanks to google/go-github.

Authentication

When it comes to authentication security is important. The login process connects to PagerDuty using Proof Key for Code Exchange (PKCE). The PagerDuty API PKCE docs did a decent job of explaining how to use it. At the moment the app is only requesting read access to PagerDuty but at some point I’d like to expand this to write access as well so that you can acknowledge the alerts directly from the app. Because PKCE is part of an oauth workflow I never had to touch the user’s username/password. The authentication and authorization all happen on the PagerDuty side.

Next I had to come up with a way to securely store the resulting API Token. I went with keybase/go-keychain which allows me to save the data into the MacOS keychain. For the cross-platform work I eventually want to do it will also allow me to save to a Linux keychain as well.

Configuring the OncallStatus.App bundle

Because this is a MacOS application I had to setup an app bundle that can be run instead of a command line tool. I found this article https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5 that walked me through how to setup the OncallStatus.app directory and files. I followed the steps for the icons, plist & folder structure. However I found an easier tool for creating DMG files so I was able to setup some automation for that step.

I was able to get an appropriately licensed image to use as application icon from Adobe Stock. At this point I could run OncallStatus as a normal MacOS app. Unfortunately the security warnings and restrictions still kept the app from being unusable.

Build, Signing & Notarizing

In order to distribute the application without all the security warnings showing up when someone tries to run OncallStatus I had to pay Apple a $99 yearly fee in order to sign & notarize it. I really hope I start making more apps like this one in order to make the cost worth it. It’s pretty annoying that Apple makes you pay to join the Developer Program in order to sign & notarize apps.

Once I paid the toll, I could use gon to do the signing & notarizing in an automated fashion. First I setup gon to sign the OncallStatus.app and the binary OncallStatus.app/Contents/MacOS/OncallStatus. I had originally tried to do the notarizing at the same time but I had trouble getting the DMG created properly when I did it that way. The binary file kept ending up in the DMG top level instead of just the OncallStatus.app. Instead after signing the app files, I create the DMG file, then send that to Apple to get notarized.

What’s really cool is that I can do all of this via a few GitHub Actions. It’s even able to automatically upload & attach the newly createdDMG file to the release when I create the new version tag. The more I use GitHub Actions the deeper I fall in love with them.

What’s coming next

As with many things time is going to be a key factor. Right now my priority is to pass the CKS exam. But once that’s out of the way I’d like to expand the functionality so that it works on Linux desktops. Several of my friends & co-workers run Linux as their primary machine and I’d like to be able to support them. I’d also like to clean up the notifications code as it’s using a deprecated library that will eventually go away. If I ever get more comfortable with Cocoa (or whatever language) for MacOS UI development I’d like to allow users to acknowledge the alert directly from the notification.

For now however, I hope you give it a try and like it. Please don’t hesitate to give feedback here or as a GitHub issue.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in GrepMyMind

Feel free to grep & grok your way through my thoughts on Kubernetes, programming, tech & other random bits of knowledge. My randomness is my own & not those of any company I might be working for. I may be right, I may be wrong, but as Deep Thought said, “42.”

Written by Mike Tougeron

Lead SRE @Adobe , #kubernetes fan & gamer (board & video). he/him. Remember, reality is all in your head…

No responses yet

Write a response