Documentation ¶
Index ¶
- Constants
- type ContextDataManager
- func (c *ContextDataManager) FetchContextData() (map[string]string, error)
- func (c *ContextDataManager) FetchManifests() error
- func (c *ContextDataManager) GetConsumesKeys(pluginName string) []string
- func (c *ContextDataManager) GetProducesKeys(pluginName string) []string
- func (c *ContextDataManager) WriteCache() error
- type Manager
- func (manager *Manager) AppendPlugin(plugin Plugin)
- func (manager *Manager) FindPlugin(parts []string) (Plugin, error)
- func (manager *Manager) GetInternalPlugins() PluginList
- func (manager *Manager) HelpTemplateFuncs() *template.FuncMap
- func (manager *Manager) ListPlugins() (PluginList, error)
- func (manager *Manager) ListPluginsForCommandGroup(commandGroupParts []string) (PluginList, error)
- func (manager *Manager) LookupInPath() bool
- func (manager *Manager) PluginsDir() string
- func (manager *Manager) Verify() VerificationErrorsAndWarnings
- type Manifest
- type Plugin
- type PluginList
- type PluginWithManifest
- type VerificationErrorsAndWarnings
- func (eaw *VerificationErrorsAndWarnings) AddError(format string, args ...interface{}) VerificationErrorsAndWarnings
- func (eaw *VerificationErrorsAndWarnings) AddWarning(format string, args ...interface{}) VerificationErrorsAndWarnings
- func (eaw *VerificationErrorsAndWarnings) HasErrors() bool
- func (eaw *VerificationErrorsAndWarnings) IsEmpty() bool
- func (eaw *VerificationErrorsAndWarnings) PrintWarningsAndErrors(out io.Writer)
Constants ¶
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 ContextDataManager ¶ added in v0.39.0
type ContextDataManager struct { //ContextData map[string]ContextData `json:"-"` PluginManager *Manager `json:"-"` Producers map[string][]string `json:"producers"` Consumers map[string][]string `json:"consumers"` Manifests map[string]Manifest `json:"manifests"` }
var CtxManager *ContextDataManager
func NewContextManager ¶ added in v0.39.0
func NewContextManager(pluginManager *Manager) (*ContextDataManager, error)
func (*ContextDataManager) FetchContextData ¶ added in v0.39.0
func (c *ContextDataManager) FetchContextData() (map[string]string, error)
func (*ContextDataManager) FetchManifests ¶ added in v0.39.0
func (c *ContextDataManager) FetchManifests() error
FetchManifests it tries to retrieve manifest from both inlined and external plugins
func (*ContextDataManager) GetConsumesKeys ¶ added in v0.39.0
func (c *ContextDataManager) GetConsumesKeys(pluginName string) []string
GetConsumesKeys returns array of keys consumed by plugin
func (*ContextDataManager) GetProducesKeys ¶ added in v0.39.0
func (c *ContextDataManager) GetProducesKeys(pluginName string) []string
GetProducesKeys returns array of keys produced by plugin
func (*ContextDataManager) WriteCache ¶ added in v0.39.0
func (c *ContextDataManager) WriteCache() error
WriteCache store data back to cache file
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
NewManager creates a new manager for looking up plugins on the file system
func (*Manager) AppendPlugin ¶ added in v0.38.0
func (*Manager) FindPlugin ¶
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) GetInternalPlugins ¶ added in v0.39.0
func (manager *Manager) GetInternalPlugins() PluginList
func (*Manager) HelpTemplateFuncs ¶
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 ¶
LookupInPath returns true if plugins should be also looked up within the path
func (*Manager) PluginsDir ¶
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 Manifest ¶ added in v0.39.0
type Manifest struct { // Path to external plugin binary. Always empty for inlined plugins. Path string `json:"path,omitempty"` // Plugin declares its own manifest to be included in Context Sharing feature HasManifest bool `json:"hasManifest"` // ProducesContextDataKeys is a list of keys for the ContextData that // a plugin can produce. Nil or an empty list declares that this // plugin is not ContextDataProducer ProducesContextDataKeys []string `json:"producesKeys,omitempty"` // ConsumesContextDataKeys is a list of keys from a ContextData that a // plugin is interested in to consume. Nil or an empty list declares // that this plugin is not a ContextDataConsumer ConsumesContextDataKeys []string `json:"consumesKeys,omitempty"` }
Manifest represents plugin metadata
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 PluginWithManifest ¶ added in v0.39.0
type PluginWithManifest interface { // Plugin original interface wrapper Plugin // GetManifest GetManifest() *Manifest // GetContextData GetContextData() map[string]string // ExecuteWithContext ExecuteWithContext(ctx map[string]string, args []string) error }
PluginWithManifest represents extended plugin support for Manifest and Context Sharing feature
type VerificationErrorsAndWarnings ¶
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)