registry

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRepoDefined   = errors.New("repository is already defined")
	ErrUnknownPlugin = errors.New("unknown plugin name")
)

Common errors returned by the registry package.

Functions

func DecodeIndex

func DecodeIndex(path string, reader io.Reader) (*structs.RepositoryIndex, error)

DecodeIndex decodes a repository index file from reader. The path is required to detect the correct encoding.

Supported file extensions are .yaml, .json and .hcl.

func ValidateIndex

func ValidateIndex(index *structs.RepositoryIndex) error

ValidateIndex validates all plugin configurations in index and returns a list of validation errors. A non-nil error is always of type *multierror.Error.

If no errors are found, nil is returned.

Types

type Registry

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

Registry manages one or more plugin repositories, fetches their index files and provides access to available plugins.

It also supports detecting available plugin updates.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry. Note that the registry does not yet contain any plugin repositories, users should call AddRepository() and finally update the registry by calling Fetch().

func (*Registry) AddRepository

func (reg *Registry) AddRepository(repo structs.Repository) error

AddRepository adds a new repository to the registry.

func (*Registry) ByName

func (reg *Registry) ByName(name string) (structs.PluginDesc, bool)

ByName returns the plugin by name.

func (*Registry) Fetch

func (reg *Registry) Fetch() error

Fetch fetches the repository index files and update the local list of available plugins.

func (*Registry) ListPlugins

func (reg *Registry) ListPlugins() []structs.PluginDesc

ListPlugins returns a list of available plugins.

func (*Registry) SearchByName

func (reg *Registry) SearchByName(name string) []structs.PluginDesc

SearchByName returns a list of plugins that match name.

func (*Registry) SearchByTag

func (reg *Registry) SearchByTag(searchTag string) []structs.PluginDesc

SearchByTag returns a list of plugins that contain searchTag in their tag list.

func (*Registry) SearchByType

func (reg *Registry) SearchByType(pType shared.PluginType) []structs.PluginDesc

SearchByType returns a list of plugins that implement type.

func (*Registry) UpdateAvailable

func (reg *Registry) UpdateAvailable(plgName string, currentVersion string) (string, error)

UpdateAvailable checks if an update to plgName is available. It compares the version of the loaded repositories with the current version and returns the available version if it is higher than the current one.

If no update is available and empty string and a nil error is returned. If there is no such plugin available ErrUnknownPlugin is returned. In case any of the version cannot be parsed an error is returned.

Jump to

Keyboard shortcuts

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