Installing Cloud Foundry CLI plugins

Plugins are a wonderful way for anyone to contribute new features – big or small – to Cloud Foundry users. Either to internal only users or to the world-wide federation of Cloud Foundry users public and private.

Unfortunately, it has been a little painful to find, compile and install CLI plugins. You needed golang, you needed to know how to find them with github search, etc.

Fortunately, the very latest CLI (v6.10.0 or later) supports plugin discovery and plugin installation from community lists. Public community lists or internal private lists. Awesome.

Here’s how to get started with the community list. Click below to see the growing registry of plugins that can be easily installed:

plugin ui

First, confirm that you are using v6.10.0 or later:

$ cf -v
cf version 6.10.0-b78bf10-2015-02-11T22:26:40+00:00

Now, you need to add the plugin registry to your local cf:

$ cf add-plugin-repo community http://plugins.cfapps.io/

Note, that the UI is http://plugins.cfapps.io/ui/ and the cf add-plugin-repo URL is just http://plugins.cfapps.io/

You can see that you have registered this plugin registry:

$ cf list-plugin-repos
OK
Repo Name   Url
community   http://plugins.cfapps.io/

What plugins are available? I’m glad you asked!

$ cf repo-plugins community
Getting plugins from all repositories ...
Repository: community
name           version   description
CLI-Recorder   1.0.1     Records and playbacks CLI commands.
Live Stats     1.0.0     Monitor CPU and Memory usage on an app via the browser.
Console        1.0.0     Start a tmate session on an application container
Diego-Beta     1.0.0     Enables Diego-specific commands and functionality
Open           1.1.0     Open app url in browser

"Open app url in a browser"? That sounds awesome. Let’s install that.

$ cf install-plugin Open -r community

The plugin name in the "community" registry is "Open".

The output looks like:

$ cf install-plugin Open -r community
Looking up 'Open' from repository 'community'
8056016 bytes downloaded...
Installing plugin /home/ubuntu/tmp/cf-plugin-open...
OK
Plugin open v1.1.0 successfully installed.

What commands did this plugin give us?

$ cf plugins
Listing Installed Plugins...
OK
Plugin Name   Version   Command Name   Command Help
open          1.1.0     open           open app url in browser
open          1.1.0     service-open   open service instance dashboard in browser

Two new cf commands have been added:

  • cf open APPNAME
  • cf service-open SERVICENAME

The ability for anyone to quicky write new plugins and share them within the world of Cloud Foundry users is fantastic and far reaching.

Write your own plugin

Here are the instructions for writing your own Cloud Foundry CLI plugin – https://github.com/cloudfoundry/cli/tree/master/plugin_examples

All plugins are written in Go.

To share them you need to pre-compile your plugin for the following targets:

  • OS X osx
  • Windows win64
  • Linux 64bit linux64

Then you must upload these to the internet. I recommend uploading them to a Github repository release.

https://github.com/aktau/github-release is a wonderful tool for creating github releases and uploading assets (your compiled CF plugins).

Some projects have been including the compiled binaries in their git repos; but I think this isn’t a great plan going forward. Repos will explode in size over time, for example.

Finally, submit a PR to the plugin registry that you want to share it with. For the community registry above you would submit a PR to https://github.com/cloudfoundry-incubator/cli-plugin-repo/blob/master/repo-index.yml for each new release.

Hosting your own plugin registry

https://github.com/cloudfoundry-incubator/cli-plugin-repo is also the project that you can deploy to host your own private plugin registry within your organization.

Spread the word

twitter icon facebook icon linkedin icon