plugin

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package plugin defines the engine-independent contract for local render plugins.

Index

Constants

View Source
const MaxMessageBytes = 64 << 20

MaxMessageBytes bounds each serialized protobuf request and response (64 MiB).

View Source
const ProtocolVersion = 1

Variables

This section is empty.

Functions

func Object

func Object(resource Resource) (map[string]any, error)

Object decodes exactly one Kubernetes object, retaining YAML scalar types.

func ObjectID

func ObjectID(object map[string]any) (string, error)

ObjectID returns the concrete Kubernetes identity used across render engines.

func Serve

func Serve(ctx context.Context, socket string, service Service) (result error)

Serve serves one persistent engine on a Unix socket until cancellation or a termination signal. Engines must honor RPC cancellation and support concurrent calls. Shutdown cancels outstanding calls before releasing engine resources. An engine implementing Close() error is closed exactly once, including on listener setup failure. Existing socket paths are never removed on startup.

Types

type Client

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

Client owns a persistent connection and its executable. Close is idempotent and must be called by the owner; cancellation of Start's context also closes the client. Failed/uncertain RPCs invalidate the complete engine process.

func Start

func Start(ctx context.Context, command Command) (*Client, error)

Start launches a trusted executable, appending --socket and a private socket path to its arguments, and verifies Describe before returning it.

func StartWithOptions

func StartWithOptions(ctx context.Context, command Command, options Options) (*Client, error)

StartWithOptions is Start with configurable transport timeouts.

func (*Client) Close

func (c *Client) Close() error

Close disconnects, signals the whole child process group, then kills it after the shutdown bound. It also kills surviving descendants after the leader exits.

func (*Client) CloseRender

func (c *Client) CloseRender(ctx context.Context, request *CloseRequest) (*CloseResponse, error)

func (*Client) Describe

func (c *Client) Describe(ctx context.Context, request *DescribeRequest) (*DescribeResponse, error)

func (*Client) Expand

func (c *Client) Expand(ctx context.Context, request *ExpandRequest) (*ExpandResponse, error)

func (*Client) OpenRender

func (c *Client) OpenRender(ctx context.Context, request *OpenRequest) (*OpenResponse, error)

type CloseRequest

type CloseRequest struct {
	Session string `json:"session"`
}

type CloseResponse

type CloseResponse struct{}

type Command

type Command struct {
	Name    string          `json:"name" yaml:"name"`
	Command string          `json:"command" yaml:"command"`
	Args    []string        `json:"args,omitempty" yaml:"args,omitempty"`
	Config  json.RawMessage `json:"config,omitempty" yaml:"-"`
}

Command selects an executable from trusted startup configuration.

type DescribeRequest

type DescribeRequest struct {
	ProtocolVersion int `json:"protocolVersion"`
}

type DescribeResponse

type DescribeResponse struct {
	ProtocolVersion int    `json:"protocolVersion"`
	Name            string `json:"name"`
	Version         string `json:"version"`
}

type Diagnostic

type Diagnostic struct {
	Code       string `json:"code"`
	Message    string `json:"message"`
	Severity   string `json:"severity"`
	ResourceID string `json:"resourceId,omitempty"`
}

type ExpandRequest

type ExpandRequest struct {
	Session   string     `json:"session"`
	Resources []Resource `json:"resources"`
}

type ExpandResponse

type ExpandResponse struct {
	Expansions  []Expansion       `json:"expansions"`
	Diagnostics []Diagnostic      `json:"diagnostics"`
	Evidence    []json.RawMessage `json:"evidence,omitempty"`
}

ExpandResponse exhaustively describes all producers and current diagnostics. Evidence is informational and must never be fed back as observed cluster state.

type Expansion

type Expansion struct {
	ID        string     `json:"id"`
	Trigger   string     `json:"trigger"`
	Resources []Resource `json:"resources"`
}

Expansion is a complete replacement of one producer's current desired output. Trigger is an inventory identity, or "root" for the configured source roots.

type OpenRequest

type OpenRequest struct {
	RunID        string          `json:"runId,omitempty"`
	Root         string          `json:"root"`
	Paths        []string        `json:"paths"`
	Recursive    bool            `json:"recursive"`
	LocalOnly    bool            `json:"localOnly"`
	StrictInputs bool            `json:"strictInputs"`
	Cluster      string          `json:"cluster,omitempty"`
	Fresh        bool            `json:"fresh,omitempty"`
	Config       json.RawMessage `json:"config,omitempty"`
}

OpenRequest is trusted invocation configuration, never an instruction derived from Kubernetes annotations. A session belongs to one cluster and evaluation.

type OpenResponse

type OpenResponse struct {
	Session string `json:"session"`
}

type Options

type Options struct {
	StartupTimeout  time.Duration // Default 10 seconds.
	RPCTimeout      time.Duration // Default 2 minutes, including render calls.
	ShutdownTimeout time.Duration // Default 10 seconds before SIGKILL, allowing runtime cleanup.
}

Options configures transport bounds. Zero durations select defaults; negative durations are invalid. Caller deadlines are always respected when shorter.

type Provenance

type Provenance struct {
	Kind      string `json:"kind,omitempty"`
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Path      string `json:"path,omitempty"`
	Text      string `json:"text,omitempty"`
}

type Resource

type Resource struct {
	ID         string     `json:"id"`
	YAML       string     `json:"yaml"`
	Logical    bool       `json:"logical,omitempty"`
	Provenance Provenance `json:"provenance"`
}

Resource is desired YAML and its stable preview identity. Logical identities identify unnamed composition outputs without inventing Kubernetes names.

func ParseResource

func ParseResource(data []byte, provenance Provenance) (Resource, error)

ParseResource validates named YAML and attaches out-of-band provenance.

type Service

Service is implemented by engines and by the persistent gRPC client Adapter.

Jump to

Keyboard shortcuts

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