Developing cf CLI Plugins
Page last updated:
Warning: VMware Tanzu Application Service for VMs (TAS for VMs) v2.9 is no longer supported because it has reached the End of General Support (EOGS) phase as defined by the Support Lifecycle Policy. To stay up to date with the latest software and security updates, upgrade to a supported version.
This topic describes creating and installing Cloud Foundry Command Line Interface (cf CLI) plugins.
You can create and install cf CLI plugins to provide custom commands. You can submit and share these plugins to the CF Community repository.
To use plugins, you must use cf CLI v.6.7 or later. For information about downloading, installing, and uninstalling the cf CLI, see Installing the Cloud Foundry Command Line Interface.
To prepare to create a plugin:
Implement the predefined plugin interface from plugin.go in the Cloud Foundry CLI repository on GitHub.
To initialize a plugin:
From within the
main()method of your plugin, call:
plugin.Start(...)function requires a new reference to the
structthat implements the defined interface.
To invoke cf CLI commands,
From within the
Run(...)method of your plugin, call:
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 occurs if the call to the cf CLI command fails.
For more information, see Plugin API in the Cloud Foundry CLI repository on GitHub.
To install a plugin:
cf install-plugin PATH-TO-PLUGIN-BINARY
PATH-TO-PLUGIN-BINARYis the path to your plugin binary.
For more information about developing plugins, see plugin_examples in the Cloud Foundry CLI repository on GitHub.