plugin

package
v1.3.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DependencyDirEnvName define environment variable where plugin dependency binaries are stored.
	DependencyDirEnvName = "PLUGIN_DEPENDENCY_DIR"
)

Variables

View Source
var ErrNotStartedPluginManager = errors.New("plugin manager is not started yet")

ErrNotStartedPluginManager is an error returned when Plugin Manager was not yet started and initialized successfully.

Functions

func DoesBinaryExist added in v0.18.0

func DoesBinaryExist(path string) bool

DoesBinaryExist returns true if a given file exists.

func DownloadBinary added in v0.18.0

func DownloadBinary(ctx context.Context, destPath string, url URL) error

DownloadBinary downloads binary into specific destination.

func GenerateKubeConfig added in v1.0.0

func GenerateKubeConfig(restCfg *rest.Config, clusterName string, pluginCtx config.PluginContext, input KubeConfigInput) ([]byte, error)

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true if one of the error in the chain is the not found error instance.

func NewPluginLoggers

func NewPluginLoggers(bkLogger logrus.FieldLogger, logConfig config.Logger, pluginKey string, pluginType Type) (hclog.Logger, io.Writer, io.Writer)

NewPluginLoggers returns a copy of parent with a log settings dedicated for a given plugin. The log level is taken from the environment variable with a pattern: LOG_LEVEL_{pluginType}_{pluginRepo}_{pluginName}. If env variable is not set, default value is "info". Loggers: - hashicorp client logger always has the configured log level - binary standard output is logged only if debug level is set, otherwise it is discarded - binary standard error is logged always on error level

Types

type Collector

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

Collector provides functionality to collect all enabled plugins based on the Botkube configuration.

func NewCollector

func NewCollector(log logrus.FieldLogger) *Collector

NewCollector returns a new Collector instance.

func (*Collector) GetAllEnabledAndUsedPlugins

func (c *Collector) GetAllEnabledAndUsedPlugins(cfg *config.Config) ([]string, []string)

GetAllEnabledAndUsedPlugins returns the list of all plugins that are both enabled and bind to at least one communicator or action (automation) that is enabled.

type Dependencies added in v0.18.0

type Dependencies map[string]Dependency

Dependencies holds the dependencies for a given platform binary.

type Dependency added in v0.18.0

type Dependency struct {
	URL string `yaml:"url"`
}

Dependency holds the dependency information.

type Index

type Index struct {
	Entries []IndexEntry `yaml:"entries"`
}

Index defines the plugin repository index.

func (Index) Validate

func (in Index) Validate() error

Validate validates that entries define in a given index don't conflict with each other by having the same name, type and version.

type IndexBuilder

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

IndexBuilder provides functionality to generate plugin index.

func NewIndexBuilder

func NewIndexBuilder(log logrus.FieldLogger) *IndexBuilder

NewIndexBuilder returns a new IndexBuilder instance.

func (*IndexBuilder) Build

func (i *IndexBuilder) Build(dir, urlBasePath, pluginNameFilter string, skipChecksum bool) (Index, error)

Build returns plugin index built based on plugins found in a given directory.

type IndexEntry

type IndexEntry struct {
	Name        string     `yaml:"name"`
	Type        Type       `yaml:"type"`
	Description string     `yaml:"description"`
	Version     string     `yaml:"version"`
	URLs        []IndexURL `yaml:"urls"`
	JSONSchema  JSONSchema `yaml:"jsonSchema"`
}

IndexEntry defines the plugin definition.

type IndexURL

type IndexURL struct {
	URL          string           `yaml:"url"`
	Checksum     string           `yaml:"checksum"`
	Platform     IndexURLPlatform `yaml:"platform"`
	Dependencies Dependencies     `yaml:"dependencies,omitempty"`
}

IndexURL holds the binary url details.

type IndexURLPlatform

type IndexURLPlatform struct {
	OS   string `yaml:"os"`
	Arch string `yaml:"architecture"`
}

IndexURLPlatform holds platform information about a given binary URL.

type JSONSchema added in v0.18.0

type JSONSchema struct {
	Value  string `yaml:"value,omitempty"`
	RefURL string `yaml:"refURL,omitempty"`
}

type KubeConfigInput added in v1.0.0

type KubeConfigInput struct {
	Channel string
}

type Manager

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

Manager provides functionality for managing executor and source plugins.

func NewManager

func NewManager(logger logrus.FieldLogger, logCfg config.Logger, cfg config.PluginManagement, executors, sources []string) *Manager

NewManager returns a new Manager instance.

func (*Manager) GetExecutor

func (m *Manager) GetExecutor(name string) (executor.Executor, error)

GetExecutor returns the executor client for a given plugin.

func (*Manager) GetSource

func (m *Manager) GetSource(name string) (source.Source, error)

GetSource returns the source client for a given plugin.

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown performs any necessary cleanup. This method blocks until all cleanup is finished.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start downloads and starts all enabled plugins.

type NotFoundPluginError

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

NotFoundPluginError is an error returned when a given Plugin cannot be found in a given repository.

func NewNotFoundPluginError

func NewNotFoundPluginError(msg string, args ...any) *NotFoundPluginError

NewNotFoundPluginError return a new NotFoundPluginError instance.

func (NotFoundPluginError) Error

func (n NotFoundPluginError) Error() string

Error returns the error message.

func (*NotFoundPluginError) Is

func (n *NotFoundPluginError) Is(target error) bool

Is returns true if target is not found error.

type TmpDir added in v1.2.0

type TmpDir string

func (TmpDir) Get added in v1.2.0

func (t TmpDir) Get() (string, bool)

func (TmpDir) GetDirectory added in v1.2.0

func (t TmpDir) GetDirectory() string

type Type

type Type string

Type represents the plugin type.

const (
	// TypeSource represents the source plugin.
	TypeSource Type = "source"
	// TypeExecutor represents the executor plugin.
	TypeExecutor Type = "executor"
)

func (Type) IsValid

func (t Type) IsValid() bool

IsValid checks if type is a known type.

func (Type) String

func (t Type) String() string

String returns a string type representation.

type URL added in v1.1.0

type URL struct {
	URL      string
	Checksum string
}

Jump to

Keyboard shortcuts

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