plugin

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserExecute  = 1 << 6
	GroupExecute = 1 << 3
	OtherExecute = 1 << 0
)

permission bits for execute

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func NewManager

func NewManager(pluginDir string, lookupInPath bool) *Manager

NewManager creates a new manager for looking up plugins on the file system

func (*Manager) FindPlugin

func (manager *Manager) FindPlugin(parts []string) (Plugin, error)

FindPlugin checks if a plugin for the given parts exist and return it. The args given must not contain any options and contain only the commands (like in [ "source", "github" ] for a plugin called 'kn-source-github' The plugin with the most specific (longest) name is returned or nil if non is found. An error is returned if the lookup fails for some reason like an io error

func (*Manager) HelpTemplateFuncs

func (manager *Manager) HelpTemplateFuncs() *template.FuncMap

HelpTemplateFuncs returns a function map which can be used in templates for resolving plugin related help messages

func (*Manager) ListPlugins

func (manager *Manager) ListPlugins() (PluginList, error)

ListPlugins lists all plugins that can be found in the plugin directory or in the path (if configured)

func (*Manager) ListPluginsForCommandGroup

func (manager *Manager) ListPluginsForCommandGroup(commandGroupParts []string) (PluginList, error)

ListPluginsForCommandGroup lists all plugins that can be found in the plugin directory or in the path (if configured), and which fits to a command group

func (*Manager) LookupInPath

func (manager *Manager) LookupInPath() bool

LookupInPath returns true if plugins should be also looked up within the path

func (*Manager) PluginsDir

func (manager *Manager) PluginsDir() string

PluginsDir returns the configured directory holding plugins

func (*Manager) Verify

func (manager *Manager) Verify() VerificationErrorsAndWarnings

Verification of a ll plugins. This method returns all errors and warnings for the verification. The following criteria are verified (for each plugin): * If the plugin is executable * If the plugin is overshadowed by a previous plugin

type Plugin

type Plugin interface {
	// Get the name of the plugin (the file name without extensions)
	Name() string

	// Execute the plugin with the given arguments
	Execute(args []string) error

	// Return a description of the plugin (if support by the plugin binary)
	Description() (string, error)

	// The command path leading to this plugin.
	// Eg. for a plugin "kn source github" this will be [ "source", "github" ]
	CommandParts() []string

	// Location of the plugin where it is stored in the filesystem
	Path() string
}

Interface describing a plugin

type PluginList

type PluginList []Plugin

Used for sorting a list of plugins

var InternalPlugins PluginList

Allow plugins to register to this slice for inlining

func (PluginList) Len

func (p PluginList) Len() int

func (PluginList) Less

func (p PluginList) Less(i, j int) bool

func (PluginList) Swap

func (p PluginList) Swap(i, j int)

type VerificationErrorsAndWarnings

type VerificationErrorsAndWarnings struct {
	Errors   []string
	Warnings []string
}

Collection of errors and warning collected during verifications

func (*VerificationErrorsAndWarnings) AddError

func (eaw *VerificationErrorsAndWarnings) AddError(format string, args ...interface{}) VerificationErrorsAndWarnings

func (*VerificationErrorsAndWarnings) AddWarning

func (eaw *VerificationErrorsAndWarnings) AddWarning(format string, args ...interface{}) VerificationErrorsAndWarnings

func (*VerificationErrorsAndWarnings) HasErrors

func (eaw *VerificationErrorsAndWarnings) HasErrors() bool

func (*VerificationErrorsAndWarnings) IsEmpty

func (eaw *VerificationErrorsAndWarnings) IsEmpty() bool

func (*VerificationErrorsAndWarnings) PrintWarningsAndErrors

func (eaw *VerificationErrorsAndWarnings) PrintWarningsAndErrors(out io.Writer)

Jump to

Keyboard shortcuts

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