plugin

package
v3.46.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package plugin provides types for managing agent plugins.

It is intended for internal use by buildkite-agent only.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDefinitionNotFound is used when a plugin definition file cannot be
	// found.
	ErrDefinitionNotFound = errors.New("Definition file not found")

	// ErrCommandNotInPATH is the underlying error when a command cannot be
	// found during plugin validation.
	ErrCommandNotInPATH = errors.New("command not found in PATH")
)

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Name          string                 `json:"name"`
	Requirements  []string               `json:"requirements"`
	Configuration *jsonschema.RootSchema `json:"configuration"`
}

Definition defines the contents of the plugin.{yml,yaml,json} file that each plugin has.

func LoadDefinitionFromDir

func LoadDefinitionFromDir(dir string) (*Definition, error)

LoadDefinitionFromDir looks in a directory for one of plugin.json, plugin.yaml, or plugin.yml. It parses the first one it finds, and returns the resulting Definition. If none of those files can be found, it returns ErrDefinitionNotFound.

func ParseDefinition

func ParseDefinition(b []byte) (*Definition, error)

ParseDefinition parses either YAML or JSON bytes into a Definition.

type Plugin

type Plugin struct {
	// Where the plugin can be found (can either be a file system path, or
	// a git repository).
	Location string

	// The version of the plugin that should be running.
	Version string

	// The clone method.
	Scheme string

	// Any authentication attached to the repository.
	Authentication string

	// Whether the plugin refers to a vendored path.
	Vendored bool

	// Configuration for the plugin.
	Configuration map[string]any
}

Plugin describes where to find, and how to configure, an agent plugin.

func CreateFromJSON

func CreateFromJSON(j string) ([]*Plugin, error)

CreateFromJSON returns a slice of Plugins loaded from a JSON string.

func CreatePlugin

func CreatePlugin(location string, config map[string]any) (*Plugin, error)

CreatePlugin returns a Plugin for the given location and config.

func (*Plugin) ConfigurationToEnvironment

func (p *Plugin) ConfigurationToEnvironment() (*env.Environment, error)

ConfigurationToEnvironment converts the plugin configuration values to environment variables.

func (*Plugin) Identifier

func (p *Plugin) Identifier() (string, error)

Identifier returns an ID for the plugin that can be used as a folder name.

func (*Plugin) Label

func (p *Plugin) Label() string

Label returns a pretty name for the plugin.

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the name of the plugin.

func (*Plugin) Repository

func (p *Plugin) Repository() (string, error)

Repository returns the repository host where the code is stored.

func (*Plugin) RepositorySubdirectory

func (p *Plugin) RepositorySubdirectory() (string, error)

RepositorySubdirectory returns the subdirectory path that the plugin is in.

type ValidateResult

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

ValidateResult contains results of a validation check.

func (ValidateResult) Error

func (vr ValidateResult) Error() string

Error returns a single string representing all the inner error strings.

func (ValidateResult) Unwrap added in v3.42.0

func (vr ValidateResult) Unwrap() []error

Unwrap returns the errors contained in the ValidateResult.

func (ValidateResult) Valid

func (vr ValidateResult) Valid() bool

Valid reports if the result contains no errors.

type Validator

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

Validator validates plugin definitions.

func (Validator) Validate

func (v Validator) Validate(def *Definition, config map[string]any) ValidateResult

Validate checks the plugin definition for errors, including missing commands from $PATH and invalid configuration under the definition's JSON Schema.

Jump to

Keyboard shortcuts

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