plugin

package
v0.0.0-...-f9c8925 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package plugin provides the Go SDK for building dex adapters.

An adapter author implements the Adapter interface and calls Serve to start the plugin binary. The host side (dex engine) calls Open to connect. Neither side ever touches the generated protobuf types or JSON directly.

Index

Constants

This section is empty.

Variables

View Source
var Handshake = goplugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "DEX_PLUGIN",
	MagicCookieValue: "dex-plugin-v1",
}

Handshake is the shared handshake configuration both Serve and Open use. ProtocolVersion must match on both sides; the magic cookie guards against accidentally launching a non-plugin binary.

Functions

func CollectResult

func CollectResult(name string, stream grpc.ServerStreamingClient[pb.ApplyResponse], rep Reporter) (map[string]any, error)

CollectResult reads a server-streaming response, dispatching LOG/PROGRESS to the Reporter and returning the terminal SUCCESS/ERROR result. It is exported so adapter authors can use it in their own test helpers.

func Serve

func Serve(a Adapter)

Serve starts the plugin process. Call this from func main().

Types

type Adapter

type Adapter interface {
	// Apply creates or updates a resource. An empty Prior means create.
	// It returns the new state (outputs) for persistence, or an error.
	Apply(ctx context.Context, req Request, r Reporter) (map[string]any, error)

	// Destroy tears down a resource.
	Destroy(ctx context.Context, req Request, r Reporter) error
}

Adapter is the interface a dex adapter binary implements.

func Open

func Open(path string, logOut io.Writer) (Adapter, func(), error)

Open connects to an adapter binary at path and returns an Adapter client. The caller must call the returned kill func when done.

type Reporter

type Reporter interface {
	// Log sends a human-readable log message.
	Log(msg string)
	// Progress reports a percentage estimate (0-100).
	Progress(pct int)
}

Reporter receives intermediate progress from an Adapter operation.

type Request

type Request struct {
	// Name is the resource identifier from the IR.
	Name string
	// Type is the adapter resource type (e.g. "docker", "http").
	Type string
	// Properties is the desired state.
	Properties map[string]any
	// Prior is the previous desired state (nil for create).
	Prior map[string]any
	// Outputs is the resource outputs from state (only meaningful for Destroy).
	Outputs map[string]any
}

Request carries a resource operation's parameters in Go-native types.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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