Documentation ¶
Index ¶
- Variables
- func IsSafePluginName(name string) bool
- func IsSubPath(basePath, subPath string) (string, bool)
- func IsWindows() bool
- func PluginNameToBin(name string, isWindows bool) string
- func ReplaceBase(path, old, replacement string) (string, error)
- type Config
- func (c *Config) GetPlugin(pluginName string, opts FetchOpts) (Plugin, error)
- func (c *Config) Install(plugin Plugin) error
- func (c *Config) ListInstalledPlugins() (map[string]string, error)
- func (c *Config) ListPlugins() (Plugins, error)
- func (c *Config) LoadManifest(path string) (Plugin, error)
- func (c *Config) LoadPluginByName(pluginName string) (*PluginVersions, error)
- func (c *Config) LoadPluginListFromFS(indexDir string) (Plugins, error)
- func (c *Config) LoadPlugins(files []string, pluginName ...string) Plugins
- func (c *Config) Prepare() error
- func (c *Config) ReadPluginFromFile(path string) (Plugin, error)
- func (c *Config) StoreManifest(plugin Plugin, dest string) error
- func (c *Config) Uninstall(name string) error
- func (c *Config) Upgrade(pluginName string, version *semver.Version) (Plugin, error)
- type FetchOpts
- type FileOperation
- type Platform
- type Plugin
- type PluginVersions
- type Plugins
Constants ¶
This section is empty.
Variables ¶
var ( ErrIsAlreadyInstalled = errors.New("can't install, plugin is already installed") ErrIsNotInstalled = errors.New("plugin is not installed") ErrIsAlreadyUpgraded = errors.New("can't upgrade, the newest version is already installed") ErrVersionNotAvailable = errors.New("plugin version is not available") )
var IndexBranchRef = "master"
IndexBranchRef - branch to be used for index
Functions ¶
func IsSafePluginName ¶
IsSafePluginName checks if the plugin Name is safe to use.
func IsSubPath ¶
IsSubPath checks if the extending path is an extension of the basePath, it will return the extending path elements. Both paths have to be absolute or have the same root directory. The remaining path elements
func IsWindows ¶
func IsWindows() bool
IsWindows sees runtime.GOOS to find out if current execution mode is win32.
func PluginNameToBin ¶
PluginNameToBin creates the name of the symlink file for the plugin name. It converts dashes to underscores.
func ReplaceBase ¶
ReplaceBase will return a replacement path with replacement as a base of the path instead of the old base. a/b/c, a, d -> d/b/c
Types ¶
type Config ¶
type Config struct { // Paths contains all important environment paths Paths paths.Paths // Repo defines the git object required to maintain the plugin index Repo *util.GitUtil Logger *logrus.Logger }
Config defines the required
func (*Config) ListInstalledPlugins ¶
ListInstalledPlugins returns a list of all install plugins in a name:version format based on the install receipts at the specified dir.
func (*Config) ListPlugins ¶
func (*Config) LoadPluginByName ¶
func (c *Config) LoadPluginByName(pluginName string) (*PluginVersions, error)
LoadPluginByName loads a plugins index file by its name. When plugin file not found, it returns an error that can be checked with os.IsNotExist.
func (*Config) LoadPluginListFromFS ¶
LoadPluginListFromFS will parse and retrieve all plugin files.
func (*Config) LoadPlugins ¶
func (*Config) ReadPluginFromFile ¶
ReadPluginFromFile loads a file from the FS. When plugin file not found, it returns an error that can be checked with os.IsNotExist.
type FileOperation ¶
FileOperation specifies a file copying operation from plugin archive to the installation directory.
type Platform ¶
type Platform struct { URI string `json:"uri,omitempty"` Sha256 string `json:"sha256,omitempty"` Files []FileOperation `json:"files"` Selector string `json:"selector"` // Bin specifies the path to the plugin executable. // The path is relative to the root of the installation folder. // The binary will be linked after all FileOperations are executed. Bin string `json:"bin"` }
Platform describes how to perform an installation on a specific platform and how to match the target platform (os, arch).
type Plugin ¶
type Plugin struct { Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` ShortDescription string `json:"shortDescription,omitempty"` Homepage string `json:"homepage,omitempty"` Hidden bool `json:"hidden,omitempty"` Platforms []Platform `json:"platforms,omitempty"` ParsedVersion *semver.Version `json:"-"` }
Plugin describes a plugin manifest file.
func (*Plugin) ParseVersion ¶
func (p *Plugin) ParseVersion()
ParseVersion - ensures the version is valid
func (Plugin) ValidatePlugin ¶
ValidatePlugin checks for structural validity of the Plugin object with given name.
type PluginVersions ¶
PluginVersions holds manifest data for multiple versions of a plugin
func NewPluginVersions ¶
func NewPluginVersions() *PluginVersions
func (*PluginVersions) Append ¶
func (i *PluginVersions) Append(p Plugin) (err error)