Terminal Access to Builds and Deploys with the Spacepods CLI

Driven by Code
Aug 20, 2019 · 4 min read

By: Kyler Stole

The Spacepods CLI works closely with Spacepods, our internal build management and deployment tool. Learn more about how we manage infrastructure (in an abstraction we call Pods) in this post on Spacepods.

Much of the functionality in the Spacepods CLI was first implemented in a Slack bot. You can read about that in this post on SpaceBot.

The Spacepods CLI is a command line interface built in Ruby that interfaces with Spacepods. Commands built for the CLI work together to improve access to Spacepods, with the aim of increasing development efficiency throughout the company by improving the workflow involved in getting a set of changes to production.

Migrating Commands from Slack

Much of the formatting and hyperlinking abilities that Slack offers are not available on the command line. This means that command responses that were crafted to work well in Slack had to be redesigned to display in the CLI.


Like many popular Ruby gems, the Spacepods CLI is built on top of the Thor library, which provides a nice, declarative command structure. Commands work with a balance of standard Ruby and system calls. Here is an example of the command setup for an auth command.

Making the most of the limited formatting options requires heavy use of ANSI escape sequences to set the shell color. Thor helps with that as well, but we wrap it in our own utility methods, which get used throughout the codebase.

UI.success('Outputted as green and bold')
# => '\e[0m\e[32m\e[1mOutputted as green and bold\e[0m'
"String containing #{UI.bold('bolded')} text"
# => 'String containing \e[1mbolded\e[0m text'
"String containing #{UI.color('colored', [:cyan, :on_yellow])} text"
# => 'String containing \e[36m\e[43mcolored\e[0m text'


Calls from the CLI to Spacepods are similar to calls from Slack that go through SpaceBot, except the CLI runs directly on developers’ computers behind our company firewall, making the authentication scheme a tad different. Instead of leaning on Slack for authentication with email addresses to identify users, the CLI employs SSH keys. Each developer retrieves a unique user token from Spacepods that they must include with each request. The token is gathered from an endpoint by matching the user’s SSH key with the public key in their GitHub Enterprise account. We use JWT for transmission of tokens.


In Slack we used attachments to structure data. In the CLI, many commands make use of a table utility to output tabular data instead.

This can be seen in commands ported directly from SpaceBot, such as the command, which lets users list their Pods and the apps running on them; the command, which lists the latest 10 builds for a given app; and the command, which shows the deployed versions of an app on different environments.

CLI Powerhouses: SSH and RUN

While many commands are essentially ported over from Slack, SSH and RUN are two particularly useful commands that really only make sense in a terminal.

The SSH command allows developers to SSH into a box, but with the added feature of locating the right box. You provide it the name of a Pod and it works with Spacepods to find the list of IP addresses for boxes being used by that Pod. It can even narrow the list down to select an IP address for the box running a specific app on the Pod.

The RUN command takes this one step further by first SSHing into the Pod, and then using Docker to run a command on the specified container.

We are hiring! If you love solving problems, please reach out. We would love to have you join us!

Driven by Code

Technology is our art. We learn so much from the community and we want to give back. This is our contribution.

Driven by Code

Written by

Welcome to TrueCar’s technology blog, where we write about the interesting things we‘re working on. Read, engage, and come work with us!

Driven by Code

Technology is our art. We learn so much from the community and we want to give back. This is our contribution.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade