xyops

package
v0.3.0-dev.41 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 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 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 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 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 a shell 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
	// Script is the shell script run by the shellplug plugin.
	Script  string
	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 a shell event that runs one reviewed script.

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