דלג לתוכן הראשי

Flows as YAML (GitOps)

A flow is a resource: a YAML file with a name, a trigger and a list of steps. Keep the files in a repository, review changes as pull requests, and let a CI job apply them. Lumen then shows those flows as read only in the console, so the repository stays the one source of truth.

  • 15 minutes
  • lumen CLI
  • A workspace API key for CI

You need the CLI installed and signed in, and permission to edit flows in the workspace.

A flow as a file​

Every resource has apiVersion, kind, metadata and spec. This flow reads the PDFs in each email that reaches the invoices-inbox connection, merges them into one file and keeps it in Lumen. It can also be started by hand with uploaded files.

flows/gitops-invoice-pdfs.yaml
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: gitops-invoice-pdfs
namespace: tenant-acme
labels:
lumen.ai/owner: git
spec:
displayName: Invoice PDFs, merged
triggers:
- id: email
ref: {name: email-arrives}
connectorRef: {name: invoices-inbox}
config: {attachments: separate, requireAttachment: true}
next: [pdfs]
- id: manual
ref: {name: manual-run}
next: [pdfs]
nodes:
- id: pdfs
stepRef: {name: keep-pdfs}
next: [merge]
- id: merge
stepRef: {name: merge-pdfs}
next: [rename]
- id: rename
stepRef: {name: rename-file}
config: {pattern: "{date} from {sender}.pdf"}
next: [keep]
- id: keep
stepRef: {name: keep-in-lumen}

What each part is:

FieldMeaning
metadata.nameThe flow's name, lowercase with dashes. It is what lumen run and the API use.
metadata.namespaceYour workspace's namespace, tenant- followed by the workspace name. You can leave it out when you apply with -w or the workspace of your login.
lumen.ai/owner: gitSays the repository owns this flow. See Who owns a flow.
spec.displayNameThe title shown in the console.
spec.triggersWhat starts the flow. ref names the trigger, next the first steps.
spec.nodesThe steps. stepRef names the step, config is its settings, next is what follows.

The settings of every step are on its reference page, for example Send it to me by email. Run lumen explain flow.spec.nodes --recursive to see every field of a flow from your terminal.

A connection the flow needs

connectorRef names a connection that must exist in the workspace. This one is a forwarding address, the email-forward connection class:

connectors/invoices-inbox.yaml
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
name: invoices-inbox
namespace: tenant-acme
spec:
classRef: {name: email-forward}
config:
allowedSenders: ["*@supplier.example"]

Apply it first. Connections that hold a password or a key are better made with lumen connect, which asks for the secret without echoing it, so it never lands in the repository.

Check it, then apply it​

lumen apply -f flows/ --dry-run # the server checks the files and changes nothing
lumen apply -f flows/ # create or update

-f takes a file, a directory (every .yaml, .yml and .json in it) or - for standard input, and can be repeated. -o name prints only the names that were applied.

There is no separate validate command. --dry-run sends the files to the server, which runs the same checks as a real apply: every next must name a step, every placeholder must refer to a step upstream, and a step must receive what it needs. A problem is printed as the server wrote it, with the node at fault.

The apply is a server-side apply, so the same file also works with kubectl apply --server-side. Lumen records the field manager lumen, which is how it knows who changed what. Pass --force-conflicts only when you mean to take a field over from another manager.

Read a flow back​

To start from a flow you built in the console, or to see what the server holds:

lumen get flow invoices -o yaml > flows/invoices.yaml

-o yaml prints the flow the way you would write it: name, your labels and annotations and the spec, without what the server adds (uid, versions, status). Applying it again changes nothing, so lumen get flow X -o yaml | lumen apply -f - is a safe round trip. --raw prints the full object.

The console cannot export a flow as YAML. Use this command.

Who owns a flow​

Each flow has one owner, set by the label lumen.ai/owner.

OwnerWho changes itIn the console
uiThe consoleFully editable. A write from the CLI is refused.
gitThe repositoryMarked Managed in Git, read only.

A flow created from a file, the CLI or Terraform is git owned, even when the label is missing. A flow created in the console is ui owned. This keeps a sync from silently undoing a person's edit, and a person's edit from undoing the repository.

The Flows list grouped by folder. The Invoices folder lists three flows with the owner Your team. The Org agents folder lists four flows, each with a blue Managed in Git badge in the Owner column and no delete icon.The Flows list grouped by folder. The Invoices folder lists three flows with the owner Your team. The Org agents folder lists four flows, each with a blue Managed in Git badge in the Owner column and no delete icon.
Flows owned by Git show a Managed in Git badge in the Owner column and cannot be deleted here.

Open a flow that Git owns and the editor shows it read only:

The flow editor for PM triage. A blue banner reads: This flow is managed in Git, so it is read only here. You can still switch it off. A Managed in Git badge sits at the top left of the canvas, which shows a trigger tile and one step.The flow editor for PM triage. A blue banner reads: This flow is managed in Git, so it is read only here. You can still switch it off. A Managed in Git badge sits at the top left of the canvas, which shows a trigger tile and one step.
The banner says where to change the flow. The on and off switch still works.

What stays possible on a Git-owned flow, from the console: switching it on or off, running it, reading its runs, and filing it in a folder. Deleting it, and every change to its steps, happen in the repository.

Move a console flow to Git​

  1. Read the flow: lumen get flow NAME -o yaml > flows/NAME.yaml.
  2. Add lumen.ai/owner: git under metadata.labels and change nothing else in the file.
  3. Apply that file once: lumen apply -f flows/NAME.yaml.

Moving the owner is the only change the server accepts from outside the console on a flow the console owns. After it, edit the file as you like.

Take a flow back​

When a flow is only partly managed elsewhere, the console tells you: Also edited by and the name of the other manager. Take over this flow? explains that saving takes those settings over and the next change from the other source may set them back. Choose Take over and save only if you mean to make the console the owner of those fields.

Apply from CI​

A CI job signs in with an API key, not a person. In the console, open Settings, then API keys, create a key with the Build scope and store it as a secret of your CI (see API keys). The CLI takes the key from LUMEN_TOKEN and finds the workspace from it.

.github/workflows/lumen.yaml
name: Lumen flows
on:
push:
branches: [main]
paths: ["flows/**", "connectors/**"]
jobs:
apply:
runs-on: ubuntu-latest
env:
LUMEN_TOKEN: ${{ secrets.LUMEN_API_KEY }}
steps:
- uses: actions/checkout@v4
# Install the lumen binary: see "Install the CLI".
- run: lumen apply -f connectors/ -f flows/ --dry-run
- run: lumen apply -f connectors/ -f flows/

Run the dry run on pull requests and the real apply on main. With no terminal and a key in the environment, lumen never tries to open a browser; if the key is wrong or expired, the job fails with the reason.

Start a run in the same job

To check a flow after it is applied, run lumen run NAME -f sample.pdf --wait. It exits with an error if the run fails. That needs a key with the Run scope as well, or one with Admin.

One writer per field

If a person edits a flow in the console and your CI applies a file for it, one of them wins. Use the owner label so that never happens by accident.

Problems on a flow​

A flow that cannot run is not Ready. The server says why on the flow itself, step by step, in status.problems. Each problem has a path (the step or trigger at fault, such as nodes[merge]), a stable code and a message.

lumen get flows # the Ready column
lumen describe flow NAME # the status, with the problems

The usual cause is a step that needs something your installation or workspace has not set up, reported as stepUnavailable with a reason such as a mailbox that is not connected. Fix the cause, or the file, and apply again.

Next steps​