Extending ACP CLI with Plugins
You can write and install plugins to build on the default ac commands, allowing you to perform new and more complex tasks with ACP CLI and ACP platform integration.
TOC
Writing CLI Plugins
You can write a plugin for ACP CLI (ac) in any programming language or script that allows you to write command-line commands. Note that you cannot use a plugin to overwrite an existing ac command.
Creating a Simple Plugin
This procedure creates a simple Bash plugin that prints a message to the terminal when the ac foo command is issued.
Procedure
-
Create a file called
ac-foo. When naming your plugin file, keep the following in mind:- The file must begin with
ac-orkubectl-to be recognized as a plugin - The file name determines the command that invokes the plugin. For example, a plugin with the file name
ac-foo-barcan be invoked by a command ofac foo bar - You can also use underscores if you want the command to contain dashes. For example, a plugin with the file name
ac-foo_barcan be invoked by a command ofac foo-bar
- The file must begin with
-
Add the following contents to the file:
After you install this plugin for ACP CLI, it can be invoked using the
ac foocommand.
Plugin Development Requirements
- Programming Language: Use any programming language or script that supports command-line interfaces
- Naming Convention: Plugin files must follow the
ac-<plugin-name>orkubectl-<plugin-name>naming pattern - Executable: Plugin files must have executable permissions
- Command Overrides: Plugins cannot overwrite existing ACP CLI commands
- Argument Handling: Plugins should handle standard command-line arguments and flags appropriately
Additional Resources
- Review kubectl plugin development guides for implementation patterns and best practices
- Use CLI runtime utilities for Go-based plugin development
- Consider ACP platform integration when designing plugins that interact with cluster resources
Installing and Using CLI Plugins
After you write a custom plugin for ACP CLI, you must install the plugin before use.
Prerequisites
- You must have ACP CLI (ac) installed
- You must have a CLI plugin file that begins with
ac-orkubectl-
Installation Procedure
-
If necessary, update the plugin file to be executable:
-
Place the file anywhere in your PATH, such as
/usr/local/bin/: -
Run
ac plugin listto make sure that the plugin is listed:Example output
If your plugin is not listed here, verify that the file begins with
ac-orkubectl-, is executable, and is on your PATH. -
Invoke the new command or option introduced by the plugin.
For example, if you built and installed the
ac-nsplugin, you can use the following command to view the current namespace:Note that the command to invoke the plugin depends on the plugin file name. For example, a plugin with the file name of
ac-foo-baris invoked by theac foo barcommand.