sdk

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: ISC Imports: 11 Imported by: 0

Documentation

Overview

Package sdk provides the plugin author interface and helpers for implementing preflight plugins as standalone executables speaking JSON-RPC over stdin/stdout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Discover

func Discover(binaryDir string) (map[string]string, error)

Discover scans well-known directories for preflight plugins and returns a map of plugin name → absolute executable path.

Scan order (first match wins):

  1. binaryDir — directory alongside the preflight binary
  2. ~/.preflight/plugins/
  3. ./plugins/ — relative to the current working directory

On Windows, executables must have the ".exe" suffix. On all other platforms, executables have no required suffix.

func Serve

func Serve(m Module)

Serve runs the JSON-RPC loop for the given module. Call this from your plugin's main().

Types

type ApplyResult

type ApplyResult struct {
	Changed bool           `json:"changed"`
	State   map[string]any `json:"state"`
	Error   string         `json:"error,omitempty"`
}

ApplyResult is returned by a module's Apply method.

type CheckResult

type CheckResult struct {
	Changed bool           `json:"changed"`
	State   map[string]any `json:"state"`
	Error   string         `json:"error,omitempty"`
}

CheckResult is returned by a module's Check method.

type Client

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

Client is the runner-side handle for a running plugin process.

func NewClient

func NewClient(executablePath string) (*Client, error)

NewClient starts the plugin at executablePath, sends an "initialize" request, and returns a ready-to-use Client.

func (*Client) Apply

func (c *Client) Apply(args map[string]any) (ApplyResult, error)

Apply calls the plugin's apply method.

func (*Client) Check

func (c *Client) Check(args map[string]any) (CheckResult, error)

Check calls the plugin's check method.

func (*Client) Close

func (c *Client) Close() error

Close terminates the plugin process.

func (*Client) Name

func (c *Client) Name() string

Name returns the plugin's self-reported name.

type Module

type Module interface {
	// Name returns the module's canonical name (e.g. "my-module").
	Name() string
	// Check reports whether the system is already in the desired state.
	Check(args map[string]any) (CheckResult, error)
	// Apply brings the system into the desired state.
	Apply(args map[string]any) (ApplyResult, error)
}

Module is the interface plugin authors implement.

Jump to

Keyboard shortcuts

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