sdk

package module
v0.0.0-...-7ae29b8 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MPL-2.0 Imports: 12 Imported by: 8

README

Vagrant Plugin SDK

This repository is a Go library that enables users to write custom Vagrant plugins.

Plugins in Vagrant are separate binaries which communicate with the Vagrant application; the plugin communicates using gRPC, and while it is theoretically possible to build a plugin in any language supported by the gRPC framework. We recommend that the developers leverage the Vagrant SDK.

Generating protos

All Go & Ruby protos are wired into go-generate. To generate them you'll need a few binaries on your path:

You also need to ensure the output directory is present:

$ mkdir -p ruby-proto

Once that's all set up you should be ready to roll:

$ go generate .

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(opts ...Option)

Main is the primary entrypoint for plugins serving components. This function never returns; it blocks until the program is exited. This should be called immediately in main() in your plugin binaries, no prior setup should be done.

Types

type Option

type Option func(*config)

Option modifies config. Zero or more can be passed to Main.

func InProcess

func InProcess(tc *plugin.ServeTestConfig) Option

func WithComponent

func WithComponent(comp interface{}, options interface{}) Option

WithComponent registers a single component along with options for that component

func WithComponents

func WithComponents(cs ...interface{}) Option

WithComponents specifies a list of components to serve from the plugin binary. This will append to the list of components to serve. You can currently only serve at most one of each type of plugin.

func WithLogger

func WithLogger(l hclog.Logger) Option

func WithMappers

func WithMappers(ms ...interface{}) Option

WithMappers specifies a list of mappers to apply to the plugin.

Mappers are functions that take zero or more arguments and return one result (optionally with an error). These can be used to convert argument types as needed for your plugin functions. For example, you can convert a proto type to a richer Go struct.

Mappers must take zero or more arguments and return exactly one or two values where the second return type must be an error. Example:

func() *Value
func() (*Value, error)
-- the above with any arguments

This will append the mappers to the list of available mappers. A set of default mappers is always included to convert from SDK proto types to richer Go structs.

func WithName

func WithName(n string) Option

Directories

Path Synopsis
Package component has the interfaces for all the components that can be implemented.
Package component has the interfaces for all the components that can be implemented.
Package datadir manages the data directories.
Package datadir manages the data directories.
helper
path
This package provides a simple way to represent a path value and perform common operations on it.
This package provides a simple way to represent a path value and perform common operations on it.
paths
This is used for getting common Vagrant paths that are in use
This is used for getting common Vagrant paths that are in use
internal
pkg/spinner
Package spinner is a simple package to add a spinner / progress indicator to any terminal application.
Package spinner is a simple package to add a spinner / progress indicator to any terminal application.
pkg/spinner/_example
Example application that uses all of the available API options.
Example application that uses all of the available API options.
pluginargs
Package pluginargs
Package pluginargs
plugincomponent
Package plugincomponent has helpers to convert or expose component implementations for plugin proto structures.
Package plugincomponent has helpers to convert or expose component implementations for plugin proto structures.
testproto
Package testproto contains some protobuf defintions that are used in internal tests.
Package testproto contains some protobuf defintions that are used in internal tests.
internal-shared
multistep is a library for building up complex actions using individual, discrete steps.
multistep is a library for building up complex actions using individual, discrete steps.
proto
Package terminal is used by plugins to read and write to a terminal UI.
Package terminal is used by plugins to read and write to a terminal UI.

Jump to

Keyboard shortcuts

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