Skip to main content

ExtensionEntry

Struct ExtensionEntry 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.