Documentation ¶
Overview ¶
Package plugin provides the toolings to use the notation plugin.
includes a CLIManager and a CLIPlugin implementation.
Index ¶
- Variables
- type CLIInstallOptions
- type CLIManager
- func (m *CLIManager) Get(ctx context.Context, name string) (Plugin, error)
- func (m *CLIManager) Install(ctx context.Context, installOpts CLIInstallOptions) (*proto.GetMetadataResponse, *proto.GetMetadataResponse, error)
- func (m *CLIManager) List(ctx context.Context) ([]string, error)
- func (m *CLIManager) Uninstall(ctx context.Context, name string) error
- type CLIPlugin
- func (p *CLIPlugin) DescribeKey(ctx context.Context, req *proto.DescribeKeyRequest) (*proto.DescribeKeyResponse, error)
- func (p *CLIPlugin) GenerateEnvelope(ctx context.Context, req *proto.GenerateEnvelopeRequest) (*proto.GenerateEnvelopeResponse, error)
- func (p *CLIPlugin) GenerateSignature(ctx context.Context, req *proto.GenerateSignatureRequest) (*proto.GenerateSignatureResponse, error)
- func (p *CLIPlugin) GetMetadata(ctx context.Context, req *proto.GetMetadataRequest) (*proto.GetMetadataResponse, error)
- func (p *CLIPlugin) VerifySignature(ctx context.Context, req *proto.VerifySignatureRequest) (*proto.VerifySignatureResponse, error)
- type GenericPlugin
- type InstallEqualVersionError
- type Manager
- type Plugin
- type PluginDirectoryWalkError
- type PluginDowngradeError
- type PluginExecutableFileError
- type PluginMalformedError
- type SignPlugin
- type VerifyPlugin
Constants ¶
This section is empty.
Variables ¶
var ErrNotCompliant = errors.New("plugin not compliant")
ErrNotCompliant is returned by plugin methods when the response is not compliant.
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 ¶
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
func (m *CLIManager) Install(ctx context.Context, installOpts CLIInstallOptions) (*proto.GetMetadataResponse, *proto.GetMetadataResponse, error)
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.
type CLIPlugin ¶
type CLIPlugin struct {
// contains filtered or unexported fields
}
CLIPlugin implements Plugin interface to CLI plugins.
func NewCLIPlugin ¶
NewCLIPlugin returns a *CLIPlugin.
func (*CLIPlugin) DescribeKey ¶
func (p *CLIPlugin) DescribeKey(ctx context.Context, req *proto.DescribeKeyRequest) (*proto.DescribeKeyResponse, error)
DescribeKey returns the KeySpec of a key.
if ContractVersion is not set, it will be set by the function.
func (*CLIPlugin) GenerateEnvelope ¶
func (p *CLIPlugin) GenerateEnvelope(ctx context.Context, req *proto.GenerateEnvelopeRequest) (*proto.GenerateEnvelopeResponse, error)
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 ¶
func (p *CLIPlugin) GenerateSignature(ctx context.Context, req *proto.GenerateSignatureRequest) (*proto.GenerateSignatureResponse, error)
GenerateSignature generates the raw signature based on the request.
if ContractVersion is not set, it will be set by the function.
func (*CLIPlugin) GetMetadata ¶
func (p *CLIPlugin) GetMetadata(ctx context.Context, req *proto.GetMetadataRequest) (*proto.GetMetadataResponse, error)
GetMetadata returns the metadata information of the plugin.
func (*CLIPlugin) VerifySignature ¶
func (p *CLIPlugin) VerifySignature(ctx context.Context, req *proto.VerifySignatureRequest) (*proto.VerifySignatureResponse, error)
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
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
func (e PluginExecutableFileError) Error() string
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
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.