pub struct ExtensionEntry { /* private fields */ }Expand description
Entry point of p4 extension, holding the binary and global options.
§Description
The following operations are available: sample,
package, install,
delete, configure,
run,
or list.
Create and configure P4 Extensions.
Extensions are a means for customizing parts of the P4 with user-supplied logic. Extensions are self-contained packages of third-party code and assets that run within the P4 Server. Typical use cases are change submission validation, form validation, external authentication, external job fix integration, external archive integration, and command policies.
An Extension can implement custom commands that a user can run. For example, p4 extension --run myInstanceConfig validateFileSize pathToFile where validateFileSize represents a custom command and pathToFile represents an argument that is relevant to the custom command.
Extensions coexist with p4 triggers, but offer more functionality. To learn more, see Advantages over triggers in the Extension overview at P4 Server Administration Documentation.
The P4 Server runs extensions natively, without relying on external processes. Extensions run in a portable, versioned runtime with automatic replication and a programmatic API, which is documented at P4 Server Administration Documentation.
The p4 extension command requires super access granted by p4 protect. Users who are members of groups specified in the ExtAllowedGroups field of an extension’s global configuration and who are either a depot or repo owner can create or configure instances of file-based extensions to operate on the sections of the server they manage.
Extensions are versioned within the P4 Server and are stored in the built-in .p4-extensions depot. The extension depot is only accessible to the super user and by read-only commands.
Installing or upgrading an extension creates a changelist with information about pre/post install versions. Multiple revisions of an extension can be active at any given time and can be referenced by their revision number.
Implementations§
Source§impl ExtensionEntry
impl ExtensionEntry
Sourcepub fn sample(self, name: impl Into<String>) -> Extension<Sample>
pub fn sample(self, name: impl Into<String>) -> Extension<Sample>
§Description
–sample name
Create a skeleton of a new Extension in a directory. Pass it the name of the Extension to be created. (See Naming rules.) p4 extension --sample ExtName This allows you to then use the --package option.
Sourcepub fn package(self, dir: impl Into<String>) -> Extension<Package>
pub fn package(self, dir: impl Into<String>) -> Extension<Package>
§Description
–package dir
The --package option creates a packaged Extension file from the named directory of files. For example, p4 extension --package ExtName The resulting file has the same name as the directory, but with the .p4-extension suffix. An Extension must be packaged before it can be installed by using the --install option.
Sourcepub fn install(self, file: impl Into<String>) -> Extension<Install<Unselected>>
pub fn install(self, file: impl Into<String>) -> Extension<Install<Unselected>>
§Description
–install file
The full name of an Extension file on the client. The command installs it server-side. Packaged Extensions have the p4-extension file suffix. For example, p4 extension --install ExtName.p4-extension --yes
§Note
To actually perform the install or delete, the --yes option is required. Without --yes, the p4 extension command merely reports what it would do without actually performing the install or delete.
Sourcepub fn delete(self, fqn: impl Into<String>) -> Extension<Delete<Unselected>>
pub fn delete(self, fqn: impl Into<String>) -> Extension<Delete<Unselected>>
§Description
–delete extFQN
Deletes an extension, its configurations, or both. To remove the named instance config, include the --name option: p4 extension --delete myCompany::fileSizeCheck --name fileSizeCheck-instance --yes To remove all revisions of an extension and its configurations, omit the --name option: p4 extension --delete myCompany::fileSizeCheck To remove one specific revision and its instances, include the --revision option: p4 extension --delete myCompany::fileSizeCheck --revision=2 --yes To delete file-based instances registered under the specified path: p4 extension --delete ExampleInc::extD1 --path //depot/... --yes
§Note
To perform the install or delete, the --yes option is required. Without --yes, the p4 extension command merely reports what it would do without actually performing the install or delete.
extFQN means fully-qualified name: the combination of the Extension’s namespace, name, and optional depot file revision.
Sourcepub fn configure(
self,
fqn: impl Into<String>,
) -> Extension<Configure<Unselected>>
pub fn configure( self, fqn: impl Into<String>, ) -> Extension<Configure<Unselected>>
§Description
–configure extFQN
An Extension is not active until it has been configured. In this syntax: p4 extension --configure extFQN [ --revision=n ] [ -o | -i ] extFQN means fully-qualified name: the combination of the Extension’s namespace, name, and optional depot file revision. The default global configuration is: p4 extension --configure ExampleInc::myExt and your global configuration might be: p4 extension --configure myCompany::fileSizeCheck and the corresponding instance configuration might be: p4 extension --configure myCompany::extName --name Release1.0-fileSizeCheckInst An Extension can have multiple configurations, depending on the events it registers for. Each configuration of an Extension can point to a different version of the Extension.
Since 2025.2, you can prevent users from creating multiple configurations of the same extension. To learn more,, see the limit_instance field under Server Extension JSON manifest fields in the P4 Server Administration Documentation.
Sourcepub fn run(self, inst: impl Into<String>) -> Extension<Run>
pub fn run(self, inst: impl Into<String>) -> Extension<Run>
§Description
–run instName
Executes the specified Extension. An Extension can implement custom end-user commands, executed by passing the --run flag the name of an instance config and supplying any optional arguments the Extension might need.
Sourcepub fn list(self) -> Extension<List>
pub fn list(self) -> Extension<List>
§Description
–list
Displays the installed extensions and their instances. To list all Extensions: p4 extension --list --type extensions To list all instance configurations: p4 extension --list --type configs You can replace --type configs with --type global or --type instance to filter results accordingly. Adding --path path filters output to instance configurations that are path-based and their path argument matches the given path. The output of p4 extension --list --type extensions indicates the status of extension configuration: No Global Config, No Instance Config, Incomplete Global Config, Incomplete Instance Config, or OK.
§Note
For an extension to be active, an extension must have a global configuration and at least one instance configuration.