Documentation ¶
Index ¶
- Variables
- func DecodeIndex(path string, reader io.Reader) (*structs.RepositoryIndex, error)
- func ValidateIndex(index *structs.RepositoryIndex) error
- type Registry
- func (reg *Registry) AddRepository(repo structs.Repository) error
- func (reg *Registry) ByName(name string) (structs.PluginDesc, bool)
- func (reg *Registry) Fetch() error
- func (reg *Registry) ListPlugins() []structs.PluginDesc
- func (reg *Registry) SearchByName(name string) []structs.PluginDesc
- func (reg *Registry) SearchByTag(searchTag string) []structs.PluginDesc
- func (reg *Registry) SearchByType(pType shared.PluginType) []structs.PluginDesc
- func (reg *Registry) UpdateAvailable(plgName string, currentVersion string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrRepoDefined = errors.New("repository is already defined") ErrUnknownPlugin = errors.New("unknown plugin name") )
Common errors returned by the registry package.
Functions ¶
func DecodeIndex ¶
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 ¶
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 ¶
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.