Documentation
¶
Overview ¶
Package xyops declares xyOps objects (events, plugins and secrets) with john/tofu-provider-xyops, a fork of the community provider published as registry.yawn.dev/john/xyops from Forgejo releases.
Credentials come from the environment only: XYOPS_ENDPOINT and XYOPS_API_KEY (an admin key, since secrets and their grants need admin). Secret VALUES are never written: Secret manages a record's title, notes and grants; values are entered in the xyOps UI and live only in xyOps.
Event fields that hold structured data (params, fields, triggers, limits, actions) are JSON strings in the provider, as xyOps stores them; the constructs encode Go values with the same key order the provider reads back so an imported event plans without changes.
Index ¶
Constants ¶
const EventNamespace = "xyops/event"
EventNamespace is the claim namespace shared by xyOps events and workflows (a workflow is an event with a graph; both live in one ID space).
const MaxInlineScript = 16 * 1024
MaxInlineScript is a suggested bound for CheckInlineScripts: well below xySat's 64 KiB limit per environment variable, leaving room for the rest of the job environment.
const PluginNamespace = "xyops/plugin"
PluginNamespace is the claim namespace of xyOps plugins (separate from events: xyOps keeps plugins in their own ID space).
const ProviderVersion = "0.1.2-dev.9"
ProviderVersion is the pinned tofu-provider-xyops release.
Variables ¶
var Credentials = []string{"XYOPS_ENDPOINT", "XYOPS_API_KEY"}
Credentials are the environment variables the provider reads.
Functions ¶
func CheckInlineScripts ¶
CheckInlineScripts returns the addresses (sorted) of the stack's Shell Plugin events whose inline Script is longer than max bytes. xySat copies every job param into the job environment and drops a variable above 64 KiB, and each event carries its own copy of the script; move such scripts to a NewPlugin. Opt-in: call it from a consumer test, e.g. with MaxInlineScript. Plugin-backed events are never reported.
Types ¶
type Creation ¶
Creation is an xyOps event or workflow a plan would create.
type Event ¶
type Event struct {
Props EventProps
Resource *core.Resource
}
Event is a managed xyOps event.
type EventProps ¶
type EventProps struct {
ID string
// Title is always "<stack>-<ID>" (Title(stack, ID)); a set value must equal
// it. Names in the UI match the code, and two stacks can never show the
// same name for different objects.
Title string
Enabled bool
Category string
// Targets are xyOps server IDs.
Targets []string
Notes string
// Exactly one of Script and Plugin. Script is the shell script run by the
// stock Shell Plugin (shellplug): xySat copies it into the job environment
// and drops it above 64 KiB (see CheckInlineScripts). Plugin runs a custom
// Event Plugin instead; the event passes it no parameters.
Script string
Plugin *Plugin
Fields []Field
Trigger Trigger
// Concurrency is the maximum number of jobs at once (default 1).
Concurrency int
// Queue, if > 0, queues up to this many jobs for QueueSeconds.
Queue int
QueueSeconds int
// TimeoutSeconds bounds a job.
TimeoutSeconds int
// AlertWebHook, if set, is called when a job fails.
AlertWebHook string
// Actions are extra native job actions (each with its own condition),
// for example a suspend at start. Added after AlertWebHook/OnSuccess.
Actions []map[string]any
// OnSuccess launches this event (native "Run Event" action) when a job
// succeeds. The launched job gets this job's output data as its input and
// xyOps records this job as its parent; the event must have a manual trigger.
OnSuccess *EventRef
// Import adopts the existing event with this ID.
Import bool
}
EventProps configures an event that runs one reviewed program: an inline Shell Plugin Script or a custom Plugin (NewPlugin).
type EventRef ¶
EventRef names an xyOps event for use by other constructs, for example a workflow node. It is either an Event declared in this app (its resource is a dependency, so it exists first) or an event managed elsewhere (ID only; never created, imported or changed here).
type Field ¶
type Field struct {
ID string
Title string
Type string // "text" or "textarea"
Required bool
// Regex must match the whole value; xyOps rejects other input.
Regex string
Caption string
}
Field is a user parameter of an event (shown when it is run manually, accepted from a magic link). Only declared fields reach the job.
type Plugin ¶
type Plugin struct {
Props PluginProps
Resource *core.Resource
}
Plugin is a managed xyOps Event Plugin.
func NewPlugin ¶
func NewPlugin(stack *core.Stack, name string, p PluginProps) *Plugin
NewPlugin adds a custom Event Plugin. OpenTofu refuses to destroy it.
The xyOps model: when a job starts, the satellite writes Script to <temp>/plugins/<ID> and runs `Command <file>` in the job's temp directory, with the job as one JSON line on STDIN (the xyOps Wire Protocol); the program reports progress and its result as JSON lines on STDOUT.
The script is distributed to every satellite when it joins and whenever a plugin changes (xySat prepPlugins), whether or not it targets this plugin's events, so it must never contain secrets. Grant secrets to events instead. Plugin code is never copied into the job environment (xyOps sets job.script to "(File)"), unlike a Shell Plugin `script` parameter, which xySat copies into an environment variable and drops above 64 KiB.
The plugin declares no parameters (params "[]"), so a magic link or API caller can only pass an event's declared Fields. Programs must still derive their role from the scheduler-asserted job.event, never from job params: params can be supplied at run time.
type PluginProps ¶
type PluginProps struct {
ID string
// Title is always "<stack>-<ID>" (Title(stack, ID)); a set value must equal it.
Title string
// Command is the absolute path of the interpreter or binary, with optional
// fixed arguments, e.g. "/usr/bin/python3 -I". xySat appends the script path.
Command string
// Script is the program source. It is sent to every satellite: no secrets.
Script string
Notes string
// Kill selects the processes killed on abort: "all" (default), "parent"
// or "none".
Kill string
// Import adopts the existing plugin with this ID.
Import bool
}
PluginProps configures a custom xyOps Event Plugin that runs one reviewed program.
type Secret ¶
type Secret struct {
Props SecretProps
Resource *core.Resource
}
Secret is a managed xyOps secret record.
type SecretProps ¶
type SecretProps struct {
// ID is the secret's xyOps id (generated ids from the UI are fine).
ID string
// Title: "<stack>-<ID>" when empty. A UI-created secret adopted by import
// may keep its existing title.
Title string
// Notes, if empty, are left unmanaged (edited in the UI).
Notes string
// Events that receive the secret's variables in their jobs' environment.
Events []*Event
// Import adopts the existing secret with this ID.
Import bool
}
SecretProps manages an xyOps secret record and its grants, never its values.