It seems that recently every OSS tool I’ve been using during my working day (together with many other cool projects) is written in Go, so I decided to teach myself a little bit of it having fun in the meanwhile, in the not-too-rare case I’ll need to troubleshoot one of them, or simply understand better how it works. Unsurprisingly enough, the Net is full of excellent documentation material if you want to dig into Go programming without spending a single cent.
Generally I choose the next pet project trying to scratch an itch I already have, for example from time to time I want to know what’s the latest stable version of one of the tools I use to have available on my workstation or on my servers in a programmatic way, so I decided to try to write a web service which will spare me the time of scraping the project’s homepage in search of this precious information.
Thankfully, most of those projects I’m interested in are developed using Git with sources hosted by one of the main hosting platforms; they also tend to respect a SemVer versioning scheme (when you’re lucky…) adding a git tag for each new release, so for those we can easily devise the biggest stable version reading the output of the
git ls-remote command.
Where to host? Go serverless!
I’m a big fun of the serverless movement, and a tiny web service like this seems to be a perfect fit for the paradigm, so having the service running on some server which is not managed by myself feels like the only way to go. At the time writing, the only serverless platform offering good Go support (via Docker) seems to be Apache OpenWhisk (hosted on IBM Bluemix cloud).
Developing on OpenWhisk turned out to be quite fun (a special thank to James Thomas for his excellent blog posts helping me getting started smoothly), and one of the advantages of being open source, is to have a local development environment running on a Vagrant box. As if this is not already enough to make it an appealing platform, the community around the project is incredibly welcoming and most importantly very helpful troubleshooting the issues you might encounter (for example I was confused by namespaces in Bluemix and I found prompt and helpful feedback on the Slack channel which clarified my confusion very quickly).
Let’s cUrl to the chase
The result of my tinkering is this publicly usable (and useless?) proof of concept:
An Nginx instance (external to Bluemix) is providing SSL termination and URL rewriting, but the backend is a (Bluemix hosted) OpenWhisk action behind an OpenWhisk API gateway, consumable directly using the Bluemix endpoint:
The project homepage is hosted on GitHub where you could also have a look at the source code, leave comments or open issues or pull requests. It has no ambition of being neither complete nor especially useful, but it might give you some hints if you’re starting fresh on OpenWhisk (have a look at the
build.sh script for examples on how to interact with the OpenWhisk CLI).
As a side note, if you develop on MacOS platform, you might also want to install the OpenWhisk
wsk CLI tool using Homebrew and this formula I wrote] when I started to work on this project. EDIT: I’ve been told that on MacOS the suggested way to prototype on OpenWhisk is documented here, I didn’t try it yet but you might want to start from there instead.
I’m already quite satisfied with the result considering that the only goal was to start writing Go and to learn how to deploy publicly accessible actions on OpenWhisk, but if I’ll find time and will (or help) those would be some of the things I’d like to see improved:
- remove the self hosted Nginx from the stack (which is providing SSL termination and URL rewriting) to make it a 100% serverless solution
- remove the statically linked Git binary using a pure Go implementation of
- add support for most of the active and popular OSS projects
- add support for non-SemVer versions
- add other useful(?) features based on users request if any
Follow me on Twitter if you want to get updates on my technical experiments with both Go and OpenWhisk, or get+stay in touch.