LATEST VERSION: 1.9 - CHANGELOG
Pivotal Cloud Foundry v1.9

Developing cf CLI Plugins

Page last updated:

Users can create and install Cloud Foundry Command Line Interface (cf CLI) plugins to provide custom commands. These plugins can be submitted and shared to the CF Community repo.

Requirements

Using plugins requires cf CLI v.6.7 or higher. Refer to the Installing the Cloud Foundry Command Line Interface topic for information about downloading, installing, and uninstalling the cf CLI.

Installing the Architecture

  1. Implement the predefined plugin interface.
  2. Clone the template repo. You will need the basic GO plugin.

Initializing the Plugin

To initialize a plugin, call plugin.Start(new(MyPluginStruct)) from within the main() method of your plugin. The plugin.Start(...) function requires a new reference to the struct that implements the defined interface.

Invoking CLI Commands

Invoke CLI commands with cliConnection.CliCommand([]args) from within a plugin’s Run(...) method. The Run(...) method receives the cliConnection as its first argument. The cliConnection.CliCommand([]args) returns the output printed by the command and an error.

The output is returned as a slice of strings. The error will be present if the call to the CLI command fails.

For more information, see the calling CLI commands example.

Installing a Plugin

To install a plugin, run cf install-plugin PATH_TO_PLUGIN_BINARY.

For additional information about developing plugins, see the plugin development guide.

Was this helpful?
What can we do to improve?
View the source for this page in GitHub