plugin

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package plugin contains other packages related to the different plugin types and any helpers related to working with non type specific plugins.

Index

Constants

View Source
const (
	PluginPrefix = "pl"
)

PublicId prefixes for the resources in the plugin package.

Variables

This section is empty.

Functions

func GetOpts

func GetOpts(opt ...Option) options

GetOpts - iterate the inbound Options and return a struct

Types

type Option

type Option func(*options)

Option - how Options are passed as arguments.

func WithDescription

func WithDescription(desc string) Option

WithDescription provides an optional description.

func WithLimit

func WithLimit(l int) Option

WithLimit provides an option to provide a limit. Intentionally allowing negative integers. If WithLimit < 0, then unlimited results are returned. If WithLimit == 0, then default limits are used for results.

func WithName

func WithName(name string) Option

WithName provides an optional name.

func WithPublicId

func WithPublicId(with string) Option

WithPublicId provides an optional specific public ID

type Plugin

type Plugin struct {
	*store.Plugin
	// contains filtered or unexported fields
}

A Plugin enables additional logic to be used by boundary. It is owned by a scope.

func NewPlugin

func NewPlugin(opt ...Option) *Plugin

NewPlugin creates a new in memory Plugin assigned to the global scope. Name, Description are the only allowed option. All other options are ignored.

func TestPlugin

func TestPlugin(t testing.TB, conn *db.DB, name string, opt ...TestOption) *Plugin

TestPlugin creates a plugin and inserts it into the database. enables the "host" flag by default

Supported options: WithHostFlag, WithStorageFlag

func (*Plugin) SetTableName

func (c *Plugin) SetTableName(n string)

SetTableName sets the table name. If the caller attempts to set the name to "" the name will be reset to the default name.

func (*Plugin) TableName

func (c *Plugin) TableName() string

TableName returns the table name for the host plugin.

type PluginType

type PluginType int
const (
	PluginTypeUnknown PluginType = 0
	PluginTypeHost    PluginType = 1
	PluginTypeStorage PluginType = 2
)

type Repository

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

A Repository stores and retrieves the persistent types in the host package. It is not safe to use a repository concurrently.

func NewRepository

func NewRepository(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms, opt ...Option) (*Repository, error)

NewRepository creates a new Repository. The returned repository should only be used for one transaction and it is not safe for concurrent go routines to access it. WithLimit option is used as a repo wide default limit applied to all ListX methods.

func (*Repository) AddSupportFlag

func (r *Repository) AddSupportFlag(ctx context.Context, plugin *Plugin, flag PluginType) error

AddSupportFlag adds a flag in the database for the current plugin to specify that it is capable of that type's functions

func (*Repository) CreatePlugin

func (r *Repository) CreatePlugin(ctx context.Context, p *Plugin, opt ...Option) (*Plugin, error)

CreatePlugin inserts p into the repository and returns a new Plugin containing the plugin's PublicId. p is not changed. p must contain a valid ScopeID. p must not contain a PublicId. The PublicId is generated and assigned by this method, unless supplied by WithPublicId

Both p.Name and p.Description are optional. If p.Name is set, it must be unique within p.ScopeID.

p.CreateTime, p.UpdateTime, and p.Version are ignored and populated on creation.

Supported options: WithPublicId

func (*Repository) ListPlugins

func (r *Repository) ListPlugins(ctx context.Context, scopeIds []string, opt ...Option) ([]*Plugin, error)

ListPlugins returns a slice of Plugins for the scope IDs. WithLimit is the only option supported.

func (*Repository) LookupPlugin

func (r *Repository) LookupPlugin(ctx context.Context, id string, _ ...Option) (*Plugin, error)

LookupPlugin returns the Plugin for id. Returns nil, nil if no Plugin is found for id.

func (*Repository) LookupPluginByName

func (r *Repository) LookupPluginByName(ctx context.Context, name string, _ ...Option) (*Plugin, error)

LookupPluginByName returns the Plugin for a given name. Returns nil, nil if no Plugin is found with that plugin name.

type TestOption

type TestOption func(*testOptions)

TestOption - how Options are passed as arguments

func WithHostFlag

func WithHostFlag(flag bool) TestOption

WithHostFlag determines whether or not to enable the host flag for a test plugin

func WithStorageFlag

func WithStorageFlag(flag bool) TestOption

WithStorageFlag determines whether or not to enable the storage flag for a test plugin

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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