plugins

package
v0.0.0-...-d298eb8 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Plugins []Plugin `yaml:"plugins"`
	// contains filtered or unexported fields
}

func ParseDir

func ParseDir(dir string) (*Config, error)

ParseDir expects to find a plugin config file in dir. If dir is not a folder, an error is returned. The plugin config file format can be `plugins.yml` or `plugins.yaml`. If found, the file is parsed into a Config and returned. If no file from the given names above are found, then an empty config is returned, w/o errors.

func (Config) HasPlugin

func (c Config) HasPlugin(path string) bool

HasPlugin returns true if c contains a plugin with given path. Returns also true if there's a local plugin with the module name equal to that path.

func (Config) Path

func (c Config) Path() string

Path return the path of the config file.

func (*Config) Save

func (c *Config) Save() error

Save persists a config yaml to a specified path on disk. Must be writable.

type Plugin

type Plugin struct {
	// Path holds the location of the plugin.
	// A path can be local, in that case it must start with a `/`.
	// A remote path on the other hand, is an URL to a public remote git
	// repository. For example:
	//
	// path: github.com/foo/bar
	//
	// It can contain a path inside that repository, if for instance the repo
	// contains multiple plugins, for example:
	//
	// path: github.com/foo/bar/plugin1
	//
	// It can also specify a tag or a branch, by adding a `@` and the branch/tag
	// name at the end of the path. For example:
	//
	// path: github.com/foo/bar/plugin1@v42
	Path string `yaml:"path"`
	// With holds arguments passed to the plugin interface
	With map[string]string `yaml:"with,omitempty"`
	// Global holds whether the plugin is installed globally
	// (default: $HOME/.spellshape/plugins/plugins.yml) or locally for a chain.
	Global bool `yaml:"-"`
}

Plugin keeps plugin name and location.

func RemoveDuplicates

func RemoveDuplicates(plugins []Plugin) (unique []Plugin)

RemoveDuplicates takes a list of Plugins and returns a new list with only unique values. Local plugins take precedence over global plugins if duplicate paths exist. Duplicates are compared regardless of version.

func (Plugin) CanonicalPath

func (p Plugin) CanonicalPath() string

CanonicalPath returns the canonical path of a plugin (excludes version ref).

func (Plugin) HasPath

func (p Plugin) HasPath(path string) bool

HasPath verifies if a plugin has the given path regardless of version. Example: github.com/foo/bar@v1 and github.com/foo/bar@v2 have the same path so "true" will be returned.

func (Plugin) IsGlobal

func (p Plugin) IsGlobal() bool

IsGlobal returns whether the plugin is installed globally or locally for a chain.

func (Plugin) IsLocalPath

func (p Plugin) IsLocalPath() bool

IsLocalPath returns true if the plugin path is a local directory.

Jump to

Keyboard shortcuts

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