plugin

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: Apache-2.0 Imports: 23 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(ctx context.Context, base *cobra.Command, plugins []Metadata)

func CallPluginExecutable

func CallPluginExecutable(ctx context.Context, 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 Decode

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

func Encode

func Encode(path string) string

func SetPluginCommand

func SetPluginCommand(log log.Logger, 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 Completion added in v0.3.8

type Completion interface {
	SetupCompletion() error
	SetPlugins(plugins []Metadata)
}

func NewCompletion added in v0.3.8

func NewCompletion(cmd *cobra.Command, args []string) Completion

type Dependency

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

type Hook

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(name, metadataPath, version, binaryPath, outFile string) error
}

func NewInstaller

func NewInstaller(ctx context.Context) 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(ctx context.Context) 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