plugin

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Overview

Package plugin provides the toolings to use the notation plugin.

includes a CLIManager and a CLIPlugin implementation.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotCompliant = errors.New("plugin not compliant")

ErrNotCompliant is returned by plugin methods when the response is not compliant.

View Source
var ErrNotRegularFile = errors.New("plugin executable file is not a regular file")

ErrNotRegularFile is returned when the plugin file is not an regular file.

Functions

This section is empty.

Types

type CLIInstallOptions added in v1.1.0

type CLIInstallOptions struct {
	// PluginPath can be path of:
	//
	// 1. A directory which contains plugin related files. Sub-directories are
	// ignored. It MUST contain one and only one valid plugin executable file
	// following spec: https://github.com/notaryproject/specifications/blob/v1.0.0/specs/plugin-extensibility.md#installation
	// It may contain extra lib files and LICENSE files.
	// On success, these files will be installed as well.
	//
	// 2. A single plugin executable file following the spec.
	PluginPath string

	// Overwrite is a boolean flag. When set, always install the new plugin.
	Overwrite bool
}

CLIInstallOptions provides user customized options for plugin installation

type CLIManager

type CLIManager struct {
	// contains filtered or unexported fields
}

CLIManager implements Manager

func NewCLIManager

func NewCLIManager(pluginFS dir.SysFS) *CLIManager

NewCLIManager returns CLIManager for named pluginFS.

func (*CLIManager) Get

func (m *CLIManager) Get(ctx context.Context, name string) (Plugin, error)

Get returns a plugin on the system by its name.

If the plugin is not found, the error is of type os.ErrNotExist.

func (*CLIManager) Install added in v1.1.0

Install installs a plugin to the system. It returns existing plugin metadata, new plugin metadata, and error. It returns nil error if and only if the installation succeeded.

If plugin does not exist, directly install the new plugin.

If plugin already exists:

If overwrite is not set, then the new plugin version MUST be higher than the existing plugin version.

If overwrite is set, version check is skipped. If existing plugin is malfunctioning, it will be overwritten.

func (*CLIManager) List

func (m *CLIManager) List(ctx context.Context) ([]string, error)

List produces a list of the plugin names on the system.

func (*CLIManager) Uninstall added in v1.1.0

func (m *CLIManager) Uninstall(ctx context.Context, name string) error

Uninstall uninstalls a plugin on the system by its name. If the plugin dir does not exist, os.ErrNotExist is returned.

type CLIPlugin

type CLIPlugin struct {
	// contains filtered or unexported fields
}

CLIPlugin implements Plugin interface to CLI plugins.

func NewCLIPlugin

func NewCLIPlugin(ctx context.Context, name, path string) (*CLIPlugin, error)

NewCLIPlugin returns a *CLIPlugin.

func (*CLIPlugin) DescribeKey

DescribeKey returns the KeySpec of a key.

if ContractVersion is not set, it will be set by the function.

func (*CLIPlugin) GenerateEnvelope

GenerateEnvelope generates the Envelope with signature based on the request.

if ContractVersion is not set, it will be set by the function.

func (*CLIPlugin) GenerateSignature

GenerateSignature generates the raw signature based on the request.

if ContractVersion is not set, it will be set by the function.

func (*CLIPlugin) GetMetadata

GetMetadata returns the metadata information of the plugin.

func (*CLIPlugin) VerifySignature

VerifySignature validates the signature based on the request.

if ContractVersion is not set, it will be set by the function.

type GenericPlugin

type GenericPlugin interface {
	// GetMetadata returns the metadata information of the plugin.
	GetMetadata(ctx context.Context, req *proto.GetMetadataRequest) (*proto.GetMetadataResponse, error)
}

GenericPlugin is the base requirement to be an plugin.

type InstallEqualVersionError added in v1.1.0

type InstallEqualVersionError struct {
	Msg string
}

InstallEqualVersionError is returned when installing a plugin with version equal to the exisiting plugin version.

func (InstallEqualVersionError) Error added in v1.1.0

func (e InstallEqualVersionError) Error() string

Error returns the error message.

type Manager

type Manager interface {
	Get(ctx context.Context, name string) (Plugin, error)
	List(ctx context.Context) ([]string, error)
}

Manager manages plugins installed on the system.

type Plugin

type Plugin interface {
	SignPlugin
	VerifyPlugin
}

Plugin defines required methods to be an Plugin.

type PluginDirectoryWalkError added in v1.1.0

type PluginDirectoryWalkError error

PluginDirectoryWalkError is used when there is an issue with plugins directory and should suggest user to check the permission of plugin directory.

type PluginDowngradeError added in v1.1.0

type PluginDowngradeError struct {
	Msg string
}

PluginDowngradeError is returned when installing a plugin with version lower than the exisiting plugin version.

func (PluginDowngradeError) Error added in v1.1.0

func (e PluginDowngradeError) Error() string

Error returns the error message.

type PluginExecutableFileError added in v1.1.0

type PluginExecutableFileError struct {
	Msg        string
	InnerError error
}

PluginExecutableFileError is used when there is an issue with plugin executable file and should suggest user to check the existence, permission and platform/arch compatibility of plugin.

func (PluginExecutableFileError) Error added in v1.1.0

Error returns the error message.

func (PluginExecutableFileError) Unwrap added in v1.1.0

func (e PluginExecutableFileError) Unwrap() error

Unwrap returns the inner error.

type PluginMalformedError added in v1.1.0

type PluginMalformedError struct {
	Msg        string
	InnerError error
}

PluginMalformedError is used when there is an issue with plugin and should be fixed by plugin developers.

func (PluginMalformedError) Error added in v1.1.0

func (e PluginMalformedError) Error() string

Error returns the error message.

func (PluginMalformedError) Unwrap added in v1.1.0

func (e PluginMalformedError) Unwrap() error

Unwrap returns the inner error.

type SignPlugin

type SignPlugin interface {
	GenericPlugin

	// DescribeKey returns the KeySpec of a key.
	DescribeKey(ctx context.Context, req *proto.DescribeKeyRequest) (*proto.DescribeKeyResponse, error)

	// GenerateSignature generates the raw signature based on the request.
	GenerateSignature(ctx context.Context, req *proto.GenerateSignatureRequest) (*proto.GenerateSignatureResponse, error)

	// GenerateEnvelope generates the Envelope with signature based on the
	// request.
	GenerateEnvelope(ctx context.Context, req *proto.GenerateEnvelopeRequest) (*proto.GenerateEnvelopeResponse, error)
}

SignPlugin defines the required methods to be a SignPlugin.

type VerifyPlugin

type VerifyPlugin interface {
	GenericPlugin

	// VerifySignature validates the signature based on the request.
	VerifySignature(ctx context.Context, req *proto.VerifySignatureRequest) (*proto.VerifySignatureResponse, error)
}

VerifyPlugin defines the required method to be a VerifyPlugin.

Directories

Path Synopsis
Package proto defines the protocol layer for communication between notation and notation external plugin.
Package proto defines the protocol layer for communication between notation and notation external plugin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL