xyops

package
v0.3.1-dev.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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).

View Source
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.

View Source
const PluginNamespace = "xyops/plugin"

PluginNamespace is the claim namespace of xyOps plugins (separate from events: xyOps keeps plugins in their own ID space).

View Source
const ProviderVersion = "0.1.2-dev.9"

ProviderVersion is the pinned tofu-provider-xyops release.

Variables

View Source
var Credentials = []string{"XYOPS_ENDPOINT", "XYOPS_API_KEY"}

Credentials are the environment variables the provider reads.

Functions

func CheckInlineScripts

func CheckInlineScripts(stack *core.Stack, max int) []string

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.

func Provider

func Provider() core.Provider

Provider returns the pinned provider, published on registry.yawn.dev (GPG-signed SHA256SUMS; OpenTofu verifies the signature on a plain tofu init). The zip pins (SHA-256 and h1) go into the generated lock file and let `yawn providers` fill an offline mirror from the same release.

func Title

func Title(stack *core.Stack, id string) string

Title is the display name of an xyOps object owned by stack: "<stack>-<id>". xyOps IDs allow only [a-z0-9_]; the hyphen separates the stack.

Types

type Creation

type Creation struct {
	Address string `json:"address"`
	ID      string `json:"id"`
}

Creation is an xyOps event or workflow a plan would create.

func Clashes

func Clashes(creations []Creation, existing []string) []Creation

Clashes returns the creations whose ID already exists on the instance (existing = every event and workflow ID xyOps reports, from get_events). A clash means this app would take over or collide with an object it does not own: refuse, and import it or pick another ID.

func PlannedCreations

func PlannedCreations(plan io.Reader) ([]Creation, error)

PlannedCreations lists xyOps events/workflows the OpenTofu plan JSON (from `tofu show -json`) would create. Imports and in-place updates are not creations. Events and workflows share xyOps' event ID namespace.

type Event

type Event struct {
	Props    EventProps
	Resource *core.Resource
}

Event is a managed xyOps event.

func NewEvent

func NewEvent(stack *core.Stack, name string, p EventProps) *Event

NewEvent adds an event. OpenTofu refuses to destroy it.

func (*Event) Ref

func (e *Event) Ref() EventRef

Ref returns a reference to an event declared in this app.

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

type EventRef struct {
	ID       string
	Resource *core.Resource // nil for external events
}

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).

func ExternalEvent

func ExternalEvent(stack *core.Stack, id string) EventRef

ExternalEvent references an event this app does not manage. Declaring it in this app as well is refused: reference the declared Event instead.

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.

func NewSecret

func NewSecret(stack *core.Stack, name string, p SecretProps) *Secret

NewSecret adds a secret record. Only the listed events are granted; no category, plugin or web hook grants. OpenTofu refuses to destroy it.

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.

type Trigger

type Trigger struct {
	// Manual allows starting it from the UI/API.
	Manual bool
	// MagicTokenHash enables a magic link: sha256(key + event id) as hex.
	// The key itself is never written anywhere in code.
	MagicTokenHash string
}

Trigger starts an event.

Jump to

Keyboard shortcuts

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