manager

package
v0.0.0-...-5faf5c6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownPlugin = errors.New("unknown plugin")
)

Functions

This section is empty.

Types

type Manager

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

Manager manages installed plugins.

func NewManager

func NewManager(stateFile string, inst installer.Installer, reg PluginProvider, service pluginmanager.Service) *Manager

NewManager returns a new plugin manager that stores state information in stateFile and uses inst for plugin installations and reg for available plugin lookups.

func (*Manager) AvailableUpdates

func (mng *Manager) AvailableUpdates() []structs.AvailableUpdate

AvailableUpdates returns a list of available plugin updates.

func (*Manager) InstallPlugin

func (mng *Manager) InstallPlugin(ctx context.Context, name string) error

InstallPlugin installs a new plugin, updates the state file, registers it in the Portmaster.

func (*Manager) InstalledPlugins

func (mng *Manager) InstalledPlugins() []structs.InstalledPlugin

InstalledPlugins returns a list of all installed plugins.

func (*Manager) OnFetchDone

func (mng *Manager) OnFetchDone(fn func(error))

OnFetchDone registers a callback function that is invoked when the plugin provided fetched new repository data.

The provided error indicates if the fetch was successful or not.

func (*Manager) OnUpdateAvailable

func (mng *Manager) OnUpdateAvailable(fn func([]structs.AvailableUpdate))

OnUpdateAvailable registers a new callback function that is executed when new updates are available.

This is only ever fired after OnFetchDone and only if fetching repositories was successful.

func (*Manager) Start

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

Start starts the plugin manager. The manager will shutdown as soon as ctx is cancelled.

type PluginProvider

type PluginProvider interface {
	Fetch() error
	ByName(string) (structs.PluginDesc, bool)
	UpdateAvailable(name, version string) (string, error)
}

PluginProvider describes the minimum interface required by the manager. It's implemented by registry.Registry.

Jump to

Keyboard shortcuts

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