plugin

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPluginNotCompatible = errors.New("plugin is not compatible with the current platform")
)

Functions

This section is empty.

Types

type Downloader added in v0.0.7

type Downloader interface {
	Download(ctx context.Context, distribution models.Distribution, destinationFolder string) (string, error)
}

func NewDownloader added in v0.0.7

func NewDownloader(
	paths environment.Paths,
	providers map[models.ExecutableProvider]providers.DownloadProvider,
	fileDownloader download.FileDownloader,
) Downloader

type ExecutableArchive added in v0.0.5

type ExecutableArchive struct {
	Version    string            `yaml:"version"`
	Executable models.Executable `yaml:",inline"`
	ArchiveURL string            `yaml:"archiveURL"`
	SHA256Sum  string            `yaml:"sha256Sum"`
}

type Manager

type Manager interface {
	// List lists all installed plugins.
	List(ctx context.Context) ([]Receipt, error)
	// GetPluginReceipt returns the receipt of the given plugin.
	GetPluginReceipt(ctx context.Context, pluginName string) (Receipt, error)
	// Install installs a plugin.
	Install(ctx context.Context, plugin Plugin) (Receipt, error)
	// Uninstall uninstalls a plugin.
	Uninstall(ctx context.Context, plugin Plugin) error
}

Manager is the interface for managing plugins.

func NewManager

func NewManager(
	paths environment.Paths,
	downloader Downloader,
	extractor archive.Extractor,
	sha256Verifier verifier.Verifier,
) Manager

type Plugin

type Plugin struct {
	Name             string                 `yaml:"name"`
	ShortDescription string                 `yaml:"shortDescription"`
	LongDescription  string                 `yaml:"longDescription"`
	Usage            string                 `yaml:"usage"`
	Source           map[string]interface{} `yaml:"source"`
	Distributions    []models.Distribution  `yaml:"distributions"`
	Flags            []struct {
		Name        string `yaml:"name"`
		Short       string `yaml:"short"`
		Description string `yaml:"description"`
		Repeated    bool   `yaml:"required"`
		Required    bool   `yaml:"required"`
	}
}

func (Plugin) GenerateReceipt

func (p Plugin) GenerateReceipt(distribution models.Distribution) Receipt

func (Plugin) GetCompatibleDistribution

func (p Plugin) GetCompatibleDistribution() (models.Distribution, error)

type Receipt

type Receipt struct {
	Name        string            `yaml:"name"`
	Description string            `yaml:"description"`
	Executable  ExecutableArchive `yaml:"executable"`
	InstalledAt time.Time         `yaml:"installedAt"`
}

func LoadReceiptFrom

func LoadReceiptFrom(path string) (Receipt, error)

func (Receipt) Store

func (r Receipt) Store(pluginPath, destinationPath string) (Receipt, error)

Jump to

Keyboard shortcuts

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