backendplugin

package module
v0.0.0-...-c364ef4 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

README

backend-plugin

Documentation

Index

Constants

View Source
const BackendPluginName = "backend"

Variables

View Source
var Handshake = plugin.HandshakeConfig{

	ProtocolVersion:  1,
	MagicCookieKey:   "BACKEND_PLUGIN",
	MagicCookieValue: "i-solemnly-swear-i-am-up-to-no-good",
}
View Source
var Plugins = map[string]plugin.Plugin{
	BackendPluginName: &GRPCPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

func Server

func Server(impl BackendPlugin) *plugin.ServeConfig

Server creates a plugin.ServeConfig for the given BackendPlugin.

Types

type BackendPlugin

type BackendPlugin interface {
	// Configuration.
	Configure(_ context.Context, config map[string]string) error

	// Workspace operations.
	ListWorkspaces(_ context.Context) ([]string, error)
	DeleteWorkspace(_ context.Context, workspace string, force bool) error

	// State operations.
	GetStatePayload(_ context.Context, workspace string) (*Payload, error)
	PutState(_ context.Context, workspace string, data []byte) error
	DeleteState(_ context.Context, workspace string) error
	LockState(_ context.Context, workspace string, info *LockInfo) (string, error)
	UnlockState(_ context.Context, workspace, id string) error
}

type GRPCClient

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

func (*GRPCClient) Configure

func (c *GRPCClient) Configure(ctx context.Context, config map[string]string) error

func (*GRPCClient) DeleteState

func (c *GRPCClient) DeleteState(ctx context.Context, workspace string) error

func (*GRPCClient) DeleteWorkspace

func (c *GRPCClient) DeleteWorkspace(ctx context.Context, workspace string, force bool) error

func (*GRPCClient) GetStatePayload

func (c *GRPCClient) GetStatePayload(ctx context.Context, workspace string) (*Payload, error)

func (*GRPCClient) ListWorkspaces

func (c *GRPCClient) ListWorkspaces(ctx context.Context) ([]string, error)

func (*GRPCClient) LockState

func (c *GRPCClient) LockState(ctx context.Context, workspace string, info *LockInfo) (string, error)

func (*GRPCClient) PutState

func (c *GRPCClient) PutState(ctx context.Context, workspace string, data []byte) error

func (*GRPCClient) UnlockState

func (c *GRPCClient) UnlockState(ctx context.Context, workspace, id string) error

type GRPCPlugin

type GRPCPlugin struct {
	// GRPCPlugin must still implement the Plugin interface
	plugin.Plugin

	// Concrete implementation, written in Go.
	Impl BackendPlugin
	// contains filtered or unexported fields
}

func (*GRPCPlugin) GRPCClient

func (p *GRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*GRPCPlugin) GRPCServer

func (p *GRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type GRPCServer

type GRPCServer struct {
	proto.UnimplementedBackendServer

	// This is the real implementation
	Impl BackendPlugin
	// contains filtered or unexported fields
}

func (*GRPCServer) ConfigureBackend

func (s *GRPCServer) ConfigureBackend(ctx context.Context, req *proto.ConfigureBackend_Request) (*proto.Empty, error)

func (*GRPCServer) DeleteState

func (s *GRPCServer) DeleteState(ctx context.Context, req *proto.DeleteState_Request) (*proto.Empty, error)

func (*GRPCServer) DeleteWorkspace

func (s *GRPCServer) DeleteWorkspace(ctx context.Context, req *proto.DeleteWorkspace_Request) (*proto.Empty, error)

func (*GRPCServer) GetStatePayload

func (*GRPCServer) ListWorkspaces

func (*GRPCServer) LockState

func (*GRPCServer) PutState

func (s *GRPCServer) PutState(ctx context.Context, req *proto.PutState_Request) (*proto.Empty, error)

func (*GRPCServer) UnlockState

func (s *GRPCServer) UnlockState(ctx context.Context, req *proto.StateUnlock_Request) (*proto.Empty, error)

type LockInfo

type LockInfo struct {
	// Unique ID for the lock. NewLockInfo provides a random ID, but this may
	// be overridden by the lock implementation. The final value of ID will be
	// returned by the call to Lock.
	ID string

	// Terraform operation, provided by the caller.
	Operation string

	// Extra information to store with the lock, provided by the caller.
	Info string

	// user@hostname when available
	Who string

	// Terraform version
	Version string

	// Time that the lock was taken.
	Created time.Time

	// Path to the state file when applicable. Set by the Lock implementation.
	Path string
}

LockInfo is the information that is stored with a lock.

type Payload

type Payload struct {
	MD5  []byte
	Data []byte
}

Payload is the data that is stored in the state file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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