plugin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionEnv     = "ANKOR_PLUGIN_SESSION"
	ExecutionIDEnv = "ANKOR_PLUGIN_EXECUTION_ID"
	OsArgsEnv      = "ANKOR_PLUGIN_OS_ARGS"
	CommandEnv     = "ANKOR_PLUGIN_COMMAND"
	CommandLineEnv = "ANKOR_PLUGIN_COMMAND_LINE"
)
View Source
const PluginCommandAnnotation = "github.com/is-plugin"

Variables

View Source
var PluginBinary = "binary"

Functions

func AddPluginCommands

func AddPluginCommands(base *cobra.Command, plugins []Metadata, subCommand string)

func CallPluginExecutable

func CallPluginExecutable(main string, argv []string, extraEnvVars map[string]string, out io.Writer) error

CallPluginExecutable is used to set up the environment for the plugin and then call the executable specified by the parameter 'main'

func CallPluginExecutableInBackground added in v0.0.3

func CallPluginExecutableInBackground(main string, argv []string, extraEnvVars map[string]string) error

func Decode

func Decode(encoded string) ([]byte, error)

func Encode

func Encode(path string) string

func ExecutePluginHookAt added in v0.0.3

func ExecutePluginHookAt(plugin Metadata, events ...string) error

func SetPluginCommand added in v0.0.3

func SetPluginCommand(cobraCmd *cobra.Command, args []string)

func SetPlugins

func SetPlugins(p []Metadata)

Types

type Binary

type Binary struct {
	// The current OS
	OS string `json:"os"`

	// The current Arch
	Arch string `json:"arch"`

	// The binary url to download from or relative path to use
	Path string `json:"path"`
}

type Command

type Command struct {
	// SubCommand is the sub command of ankor this command should be added to
	SubCommand string `json:"subCommand,omitempty"`

	// Name is the name of the command
	Name string `json:"name"`

	// Usage is the single-line usage text shown in help
	Usage string `json:"usage"`

	// Description is a long description shown
	Description string `json:"description"`

	// BaseArgs that will be prepended to all supplied user flags for this plugin command
	BaseArgs []string `json:"baseArgs,omitempty"`
}

type Dependency added in v0.0.9

type Dependency struct {
	Name   string `json:"name"`
	Script string `json:"script,omitempty"`
}

type Hook added in v0.0.3

type Hook struct {
	// Event is the name of the event when to execute this hook
	Event string `json:"event"`

	// Background specifies if the given command should be executed in the background
	Background bool `json:"background"`

	// BaseArgs that will be prepended to all supplied user flags for this plugin command
	BaseArgs []string `json:"baseArgs,omitempty"`
}

type Installer

type Installer interface {
	DownloadMetadata(path, version string) (*Metadata, error)
	DownloadBinary(metadataPath, version, binaryPath, outFile string) error
}

func NewInstaller

func NewInstaller() Installer

type Interface

type Interface interface {
	Add(path, version string) (*Metadata, error)
	GetByName(name string) (string, *Metadata, error)
	Update(name, version string) (*Metadata, error)
	Remove(name string) error

	List() ([]Metadata, error)
}

func NewClient

func NewClient() Interface

type Metadata

type Metadata struct {
	// Name is the name of the plugin
	Name string `json:"name"`

	// Version is a SemVer 2 version of the plugin.
	Version string `json:"version"`

	// Binaries holds the binary to download for the
	// given os & arch
	Binaries []Binary `json:"binaries,omitempty"`

	// Commands are the commands that will be added to ankor
	Commands []Command `json:"commands,omitempty"`

	// Hooks list of dependencies required by the plugin
	Dependencies []Dependency `json:"dependencies,omitempty"`

	// This will be filled after parsing the metadata
	PluginFolder string `json:"pluginFolder,omitempty"`

	// Hooks are commands that will be executed at specific events
	Hooks []Hook `json:"hooks,omitempty"`
}

type NewestVersionError

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

func (*NewestVersionError) Error

func (n *NewestVersionError) Error() string

Jump to

Keyboard shortcuts

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