README
¶
claims
Terminal-based CLI for rendering claims via the claim-machinery API.
| Docs | stuttgart-things.github.io/claims |
| Releases | GitHub Releases |
| Container | ghcr.io/stuttgart-things/claims |
DEV
Prerequisites
- Go 1.25.5+
- Task (optional
- eine claim-machinery-api (
-a http://localhost:8080,CLAIM_API_URLoderclaims endpoint add; es gibt keinen localhost-Default mehr)
CLONE + RUN
# Repository klonen
git clone https://github.com/stuttgart-things/claims.git
cd claims
# Abhängigkeiten installieren
go mod tidy
# Bauen und starten
go build -o claims .
./claims render
Commands
| Command | Description |
|---|---|
claims templates |
List the claim templates, or one template's parameters (API login only) |
claims order |
Order a claim through machinery-order-service: no git token, the service opens the PR |
claims orders |
Follow orders: list, get, watch, cancel |
claims clusters |
List the management clusters orders can go to |
claims render |
Render claim templates, save locally or via Git PR |
claims encrypt |
Create a SOPS-encrypted Kubernetes Secret via Git PR |
claims delete |
Delete a claim via Git PR |
claims change (alias resize) |
Change a claim (VM size, Ansible re-run) via Git PR |
claims merge |
Merge an order, change or deletion PR (squash) after its checks |
claims list |
List claims (registry and *-xrs directories) |
claims login |
Log in to claim-machinery-api with ZITADEL (device flow) |
claims logout |
Forget the cached login for an API URL |
claims whoami |
Show the user, roles and groups claims sends to the API |
claims endpoint |
Named API endpoints: list, use, add, remove, current |
claims doctor |
Check API endpoint, login and git/GitHub credentials (changes nothing) |
claims version |
Print version information |
order: through machinery-order-service, without a git token
claims order places an order with machinery-order-service, which renders it
with your login, opens the pull request with its own GitHub identity and
follows it through merge and build
(ADR 0002). You need a
login (claims login, --api-token or client credentials), no repository and
no git token.
The service URL belongs to the endpoint (or --orders-url / $CLAIM_ORDERS_URL):
claims endpoint add labul https://claim-machinery-api.example.com \
--issuer https://zitadel.example.com --client-id <id>@claims \
--orders-url https://orders.example.com --use
At a terminal everything missing is asked for; without one (or with
--non-interactive / -o json) nothing is asked and a missing value is an
error naming the flag (ADR 0001):
claims templates # what can I order?
claims templates native-vm-labul-proxmox # its parameters
claims clusters # where can it go?
claims order native-vm-labul-proxmox --cluster machinery-labul \
-p name=demo -p size=small --reason "test VM" # -> order ID, phase Ordered
claims orders watch ord-0123456789ab # PROpen (waits for a merge) ... Ready
claims orders list # yours and your teams'
claims orders cancel ord-0123456789ab # before the merge
The pull request waits for a human to merge it. --auto-merge asks the service
to merge it once its checks pass. That works only where a rule of the cluster
covers you, the template and the parameters (claims clusters lists the rules);
otherwise the order is refused with exit 3 and the reason
(machinery-order-service ADR 0002).
claims order native-vm-labul-proxmox --cluster machinery-labul \
-p name=demo -p size=small --auto-merge --wait # merged once checks pass
-o json prints the service's objects. Exit codes: 0 ok, 1 error, 2 missing or
invalid flag, 3 denied (401/403, the server's reason is shown), 4 not found.
render --stdout and --dry-run order nothing, so they ask claim-machinery-api
not to send an order notification (notify=false).
render
claims render [flags]
| Flag | Short | Description |
|---|---|---|
--api-url |
-a |
API URL (else $CLAIM_API_URL, --endpoint, the current endpoint; no localhost default) |
--endpoint |
Named endpoint from claims endpoint list (or $CLAIM_ENDPOINT) |
|
--skip-preflight |
Do not check API, login and git/GitHub credentials before starting | |
--api-token |
Bearer token for claim-machinery-api (default: $CLAIM_API_TOKEN); see API Authentication |
|
--api-oidc-token-url |
OIDC token endpoint for client credentials (default: $CLAIM_API_OIDC_TOKEN_URL) |
|
--api-oidc-client-id |
OIDC client ID (default: $CLAIM_API_OIDC_CLIENT_ID) |
|
--api-oidc-client-secret |
OIDC client secret (default: $CLAIM_API_OIDC_CLIENT_SECRET) |
|
--api-oidc-scope |
OIDC scope(s), space- or comma-separated (default: $CLAIM_API_OIDC_SCOPE) |
|
--templates |
-t |
Templates to render (comma-separated or repeated) |
--params |
-p |
Parameters as key=value pairs (comma-separated or repeated) |
--params-file |
-f |
YAML file with templates and parameters for batch rendering |
--output-dir |
-o |
Output directory for rendered files (default: /tmp) |
--dry-run |
Print output without writing files | |
--stdout |
Print the rendered YAML to stdout, write nothing (non-interactive; progress on stderr) | |
--full |
Interactive review: show the complete YAML instead of the first 15 lines | |
--single-file |
Combine all resources into one file | |
--filename-pattern |
Pattern for output filenames (default: {{.template}}-{{.name}}.yaml) |
|
--file-mode |
File write mode: overwrite (default) or append |
|
--non-interactive |
Run in non-interactive mode (for CI/CD automation) | |
--git-commit |
Commit rendered files to git | |
--git-push |
Push commits to remote (implies --git-commit) |
|
--git-branch |
Branch to use/create | |
--git-create-branch |
Create the branch if it doesn't exist | |
--git-message |
Commit message (default: auto-generated) | |
--git-remote |
Git remote name (default: origin) |
|
--git-repo-url |
Clone from URL instead of using local repo | |
--git-user |
Git username (or $GIT_USER env) |
|
--git-token |
Git token (or $GIT_TOKEN/$GITHUB_TOKEN env) |
|
--create-pr |
Create a pull request after push | |
--pr-title |
PR title (default: auto-generated) | |
--pr-description |
PR description | |
--pr-labels |
PR labels (comma-separated) | |
--pr-base |
Base branch for PR (default: main) |
Examples:
# Use the current endpoint (claims endpoint use <name>)
claims render
# A named endpoint
claims render --endpoint labul
# Custom API URL
claims render --api-url http://api.example.com:8080
# Via environment variable
CLAIM_API_URL=http://api.example.com:8080 claims render
# Multiple API endpoints (interactive: shows selector, non-interactive: uses first)
CLAIM_API_URL=http://dev-api:8080:http://staging-api:8080:http://prod-api:8080 claims render
# Save to custom directory
claims render -o ./manifests
# Dry run (preview without writing)
claims render --dry-run
# Combine all resources into single file
claims render -o ./out --single-file
# Custom filename pattern
claims render -o ./out --filename-pattern "{{.name}}.yaml"
# Render multiple templates (interactive params for each)
claims render -t vsphere-vm -t postgres-db
# Render multiple templates (comma-separated)
claims render -t vsphere-vm,postgres-db -o ./out
Append Mode
Use --file-mode=append to build multi-resource YAML files across multiple render calls:
# First render creates the file
claims render --non-interactive \
-t flux-gitrepository \
-p name=flux-infra -p url=https://github.com/stuttgart-things/flux.git \
-o ./gitrepos --filename-pattern "gitrepositories.yaml"
# Second render appends with --- separator
claims render --non-interactive \
-t flux-gitrepository \
-p name=flux-apps -p url=https://github.com/stuttgart-things/flux.git \
-o ./gitrepos --filename-pattern "gitrepositories.yaml" \
--file-mode=append
Result (gitrepos/gitrepositories.yaml):
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: flux-infra
namespace: flux-system
spec:
url: https://github.com/stuttgart-things/flux.git
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: flux-apps
namespace: flux-system
spec:
url: https://github.com/stuttgart-things/flux.git
Multiple API Endpoints
CLAIM_API_URL supports colon-separated multiple endpoints. In interactive mode, a selector is shown. In non-interactive mode, the first endpoint is used.
# Configure multiple claim-machinery-api instances
export CLAIM_API_URL=http://dev-api:8080:http://staging-api:8080:http://prod-api:8080
claims render
Interactive prompt:
? Select API endpoint
> http://dev-api:8080
http://staging-api:8080
http://prod-api:8080
Non-interactive (uses first endpoint):
CLAIM_API_URL=http://dev-api:8080:http://staging-api:8080 \
claims render --non-interactive -t my-template -p name=foo
# Connects to: http://dev-api:8080
URL colons in http://, https://, and port numbers are handled correctly — only bare : between URLs acts as a separator.
Endpoints (claims endpoint)
Named claim-machinery-api endpoints, like kube contexts, in ~/.config/claims/config.yaml (override: CLAIMS_CONFIG_FILE). Each holds the API URL and what claims login needs (issuer, client ID, optional CA file). Nothing is pre-configured.
claims endpoint add labda https://claim-machinery-api.machinery.4sthings.tiab.ssc.sva.de \
--issuer https://zitadel.sthings-infra.4sthings.tiab.ssc.sva.de --client-id <id>@claims --use
claims endpoint add labul https://claim-machinery-api.machinery-labul.sthings-vsphere.labul.sva.de
claims endpoint list # * marks the current one
claims endpoint use labul
claims endpoint current # which API a command would use, and why
claims login --endpoint labda # issuer/client-id come from the endpoint
claims render --endpoint labda
Which API a command talks to: -a/--api-url > $CLAIM_API_URL > --endpoint/$CLAIM_ENDPOINT > the current endpoint. With none of them an interactive command offers a picker and a non-interactive one fails with the fix — there is no implicit http://localhost:8080 any more; pass -a http://localhost:8080 for a local API. render, encrypt and whoami print the endpoint name with the URL. See docs/11-endpoints-preflight.md.
Preflight and claims doctor
render, encrypt and delete check before rendering, branching or committing: the API endpoint is set, answers like a claim-machinery-api and accepts the credentials; with --git-push/--create-pr a git token exists (--git-token, GIT_TOKEN, GITHUB_TOKEN, else gh auth token), the remote accepts it (git ls-remote), the branch to create does not exist yet, and the token may push to the GitHub repository. Every problem is listed at once with the flag or variable that fixes it, and the command exits 1 with nothing written. --skip-preflight skips the checks; claims doctor runs them alone.
claims doctor # current endpoint + the checkout in .
claims doctor --endpoint labul --dir ~/projects/stuttgart-things
SSH remotes (git@github.com:o/r.git) are pushed to over HTTPS with the token; claims does not use the SSH agent. If a push or PR still fails after the commit, the commit stays where it is and the error prints the commands to retry (git push, gh pr create) or undo it.
API Authentication
claim-machinery-api v0.25.0+ can require a bearer token (ZITADEL JWT) on POST /api/v1/claim-templates/{name}/order when the server sets AUTH_OIDC_ISSUER; read endpoints stay open. Authentication in claims is off by default — no Authorization header is sent unless one of the following is configured. It applies to render (interactive and non-interactive) and encrypt; flags take precedence over environment variables.
Order of precedence: --api-token / CLAIM_API_TOKEN > OAuth2 client credentials (CLAIM_API_OIDC_*) > cached claims login for the API URL.
Interactive login (humans) — OAuth2 device flow against the lab ZITADEL; the tokens are cached per API URL in ~/.config/claims/credentials.json (mode 0600, override with CLAIMS_CREDENTIALS_FILE) and refreshed automatically:
# --issuer / --client-id / --scope or CLAIM_API_LOGIN_ISSUER / _CLIENT_ID / _SCOPE
claims login --api-url https://claims.example.com/claims \
--issuer https://zitadel.example.com \
--client-id 123456789012345678@claims \
--scope "openid profile email offline_access urn:zitadel:iam:org:project:id:<project-id>:aud urn:zitadel:iam:org:projects:roles"
# open the printed URL, enter the code, approve
claims whoami --api-url https://claims.example.com/claims # user, roles, groups, requested_by ref
claims render --api-url https://claims.example.com/claims # sends the cached token
claims logout --api-url https://claims.example.com/claims # or --all
- One login per API URL: each lab may run its own ZITADEL. A second
claims loginfor the same URL reuses issuer, client ID and scope of the first. --ca-file/CLAIM_API_LOGIN_CA_FILEadds PEM roots for an issuer with a private CA (the labs' Vault PKI).- Without
offline_accessno refresh token is issued and the login ends with the access token. claimsnever setsrequested_byitself; with auth on, claim-machinery-api stamps it from the token (user:default/<preferred_username>), whichclaims whoamishows.- Setting up the ZITADEL application: see docs/10-login.md.
Static token — sent as Authorization: Bearer <token> on every API request:
export CLAIM_API_TOKEN="$(cat ~/.config/claims/token)" # or --api-token
claims render --non-interactive -f params.yaml
OAuth2 client credentials (pipelines) — the token is fetched from the IdP once and cached in-process until it expires:
export CLAIM_API_OIDC_TOKEN_URL=https://zitadel.example.com/oauth/v2/token # --api-oidc-token-url
export CLAIM_API_OIDC_CLIENT_ID=claims-ci # --api-oidc-client-id
export CLAIM_API_OIDC_CLIENT_SECRET=... # --api-oidc-client-secret
export CLAIM_API_OIDC_SCOPE="openid urn:zitadel:iam:org:project:id:<id>:aud" # optional, --api-oidc-scope
claims render --non-interactive -f params.yaml
Rules:
CLAIM_API_TOKEN/--api-tokenwins when both a static token and client credentials are set.- Client credentials need token URL, client ID and client secret; a partial set is rejected with an error naming the missing variables. The scope is optional (space- or comma-separated).
- With several
CLAIM_API_URLendpoints a static token or client credentials are used for all of them; a cached login only for the URL it was made for. - A
401from the API prints a hint namingclaims login,CLAIM_API_TOKENand theCLAIM_API_OIDC_*variables; a403means the token was accepted but lacks the order role (or the owner is outside your groups) —claims whoamishows what the token carries. - Token values are never printed or logged. Prefer environment variables over
--api-tokenso the token does not end up in shell history or process listings.
Profile-Based Template Selection
When the API serves templates from multiple profiles, interactive mode shows a profile selector first:
? Select template profile
> All profiles
Crossplane Claims
Flux Kustomizations
? Select templates to render
[ ] flux-kustomization-clusterbook-app - Clusterbook App Deployment
[ ] flux-kustomization-cert-manager-install - Flux Kustomization Cert-Manager
This requires claim-machinery-api v0.21.0+ with multiple profiles configured via TEMPLATE_PROFILE_PATH.
Non-Interactive Mode (CI/CD)
For automation and CI/CD pipelines, use --non-interactive mode:
# Single template with inline parameters
claims render --non-interactive -t vspherevm -p name=my-vm -p cpu=4 -o ./out
# Multiple parameters (comma-separated)
claims render --non-interactive -t vspherevm -p name=my-vm,cpu=4,memory=8Gi
# Render a clusterbook claim with custom API URL
CLAIM_API_URL=http://localhost:8080 claims render --non-interactive \
-t cilium-clusterbook \
-p clusterName=testcluster \
-p networkKey=10.31.103 \
-p registerDns=false \
-o output
# Batch rendering with params file
claims render --non-interactive -f params.yaml -o ./out
# YAML to stdout only (no files, no registry, no git), e.g. to pipe it on
claims render -t vspherevm -p name=my-vm --stdout | kubectl apply --dry-run=client -f -
Params file format (params.yaml):
templates:
- name: vspherevm
parameters:
name: my-vm
cpu: 4
memory: 8Gi
- name: postgresql
parameters:
name: my-database
version: "15"
GitOps Integration
Rendered manifests can be automatically committed and pushed to a git repository:
# Commit rendered files to local git repo
claims render --non-interactive -t volumeclaim-simple -p name=my-volume \
-o ./manifests --git-commit
# Commit with custom message
claims render --non-interactive -t volumeclaim-simple -p name=my-volume \
-o ./manifests --git-commit --git-message "Add volume claim for app"
# Create a new branch and commit
claims render --non-interactive -t volumeclaim-simple -p name=my-volume \
-o ./manifests --git-commit --git-create-branch --git-branch feature/add-volume
# Commit and push to remote
claims render --non-interactive -t volumeclaim-simple -p name=my-volume \
-o ./manifests --git-push
# Clone-based workflow (for CI/CD without local checkout)
claims render --non-interactive -t volumeclaim-simple -p name=my-volume \
--git-repo-url https://github.com/org/gitops-repo.git \
-o manifests --git-push --git-create-branch --git-branch feature/new-claim
Authentication:
Pushing needs a token: --git-token, GIT_TOKEN, GITHUB_TOKEN, else the gh CLI's login (gh auth token). --git-user/GIT_USER is optional (it is also the commit author). SSH remotes are pushed to over HTTPS with the token.
# Via flags
claims render ... --git-push --git-user myuser --git-token ghp_xxx
# Via environment variables
export GIT_USER=myuser
export GIT_TOKEN=ghp_xxx # or GITHUB_TOKEN for GitHub Actions
claims render ... --git-push
Pull Request Support
Automatically create pull requests after pushing changes:
# Create PR with auto-generated title/description
claims render --non-interactive -t volumeclaim-simple -p name=my-volume \
-o ./manifests --create-pr --git-create-branch --git-branch feature/add-volume
# Create PR with custom title and labels
claims render --non-interactive -t volumeclaim-simple -p name=my-volume \
-o ./manifests --create-pr --git-create-branch --git-branch feature/add-volume \
--pr-title "Add volume claim for application" \
--pr-labels "infrastructure,automated"
# Create PR with custom description
claims render --non-interactive -f params.yaml \
-o ./manifests --create-pr --git-create-branch --git-branch feature/infra-update \
--pr-title "Infrastructure update" \
--pr-description "Adding new infrastructure resources" \
--pr-base main
Requirements:
claims opens the PR through the GitHub API (claims#108), in the repository of
the checkout's origin remote. It needs a token that may create pull requests:
--git-token, else $GIT_TOKEN, else $GITHUB_TOKEN, else the gh CLI's
login (gh auth token). The gh CLI itself is not required.
Source-Path Layout (--layout source-path)
For orders that know where they belong -- the VM orders of
xr-native-vm (stuttgart-things/kcl) -- the order decides the files, not
--filename-pattern:
- a document annotated
stuttgart-things.com/target-pathgoes to that file (e.g. a dev VM's ScrapeConfig) - a document annotated
stuttgart-things.com/source-pathgoes to that file (the XR: the annotation names the file it lives in) - a document with neither goes to the file of the document before it (e.g. the dev VM's EnvironmentConfig, next to its XR)
Paths are relative to --output-dir, which is the repository root. A file
that exists already is refused (the name is taken). If a kustomization.yaml
sits next to a file, - <file> is appended as its last line (once;
resources: must be the last key); a directory without one -- like today's
machinery-orders-xrs -- is applied as a whole and gets nothing. No
claims/registry.yaml is written: the order's file with its annotations is
the record. Non-interactive only; templates with secrets are refused.
With --git-commit/--git-push/--create-pr the branch, commit message and
PR follow the Backstage templates, so the repository's checks and release
tooling treat the PR like theirs. A VM order (template type xr-native-vm)
gets create-vm's: branch vm-<name>, title
feat(machinery): VM <name> (<use_case>, <lab>) (MERGE = BAU). Flags
override them.
# Preview: every file, the kustomization lines, branch and PR title
claims render --non-interactive --layout source-path -o ~/projects/stuttgart-things \
-t native-vm-labda-vsphere -p name=my-vm -p use_case=dev -p size=large --dry-run
# Order it: branch vm-my-vm, commit, push, PR
claims render --non-interactive --layout source-path -o ~/projects/stuttgart-things \
-t native-vm-labda-vsphere -p name=my-vm -p use_case=dev -p size=large --create-pr
# ... and merge it once its checks are green (MERGE = BAU: this builds the VM)
claims render --non-interactive --layout source-path -o ~/projects/stuttgart-things \
-t native-vm-labda-vsphere -p name=my-vm -p use_case=dev -p size=large --create-pr --merge
Start from an up-to-date main: the branch is created from the current HEAD.
list
claims list [--source all|registry|xrs] [--kind K,...] [--repo DIR] [--registry FILE] [--github OWNER/NAME] [--template T] [--category C] [-o table|json]
Lists the claims of the fleet repository from two places: claims/registry.yaml
(written by claims render) and the XRs in clusters/<lab>/<infra>/*-xrs/*.yaml
(e.g. the VM orders in machinery-orders-xrs/; TEMPLATE shows the kind, PATH the
file; run-once runs are left out). The repository is the git repository around
the current directory, or --repo / $CLAIMS_REPO; the registry is
--registry / $CLAIMS_REGISTRY or <repo>/claims/registry.yaml.
--kind keeps only XRs of the given kinds (comma-separated or repeated,
case-insensitive), e.g. --kind NativeVsphereVM,NativeProxmoxVM for the VMs;
registry entries have no kind and are left out (noted on stderr).
Without a checkout of the fleet repository, and without --repo / --registry,
claims list reads both from GitHub at main: --github, else
$CLAIMS_GITHUB_REPO, else stuttgart-things/stuttgart-things. A git checkout
without *-xrs directories, such as claims itself, does not count as the fleet
repository. See Without a checkout.
delete: XRs in *-xrs directories
A claim (XR) that lives in an *-xrs directory of the fleet repository (clusters/<lab>/<infra>/<x>-xrs/, e.g. the machinery orders) is deleted file first, the same way as Backstage's request-claim-deletion / delete-claim (see the repo's clusters/labda/vsphere/machinery-xrs/README.md):
claims deleteremoves the claim's file, the run-onceScheduledRuns that apply to it (stuttgart-things.com/applies) and theirkustomization.yamlentries (orders directories have none), on the branchdelete-claim/<name>, and opens the PRDelete claim: <Kind>/<name>with the labeldelete-claim.- The fleet repository's
pr-claim-delete.yamlgates that PR (hack/claim-deletion.py verify-pr). - After the merge,
delete-claim-xr.yamlwaits for Flux and deletes the object on the management cluster.
claims never deletes anything on a cluster. It applies the rules of hack/claim-deletion.py before it writes anything:
- exactly one XR in the file
- the claim's
stuttgart-things.com/source-pathis the file itself - a path inside an
*-xrsdirectory - no ClusterStack
- each removed file listed exactly once in
kustomization.yaml
cd ~/projects/stuttgart-things && git checkout main && git pull
# by kind + name (searched in all *-xrs directories) ...
claims delete --kind NativeVsphereVM --name dev7-vm --reason "project ended" --dry-run
claims delete --kind NativeVsphereVM --name dev7-vm --reason "project ended" --create-pr
# ... or by the file (its source-path)
claims delete --source-path clusters/labda/vsphere/machinery-orders-xrs/dev7.yaml --create-pr
# interactive: pick from the *-xrs claims (automatic in a repo without claims/registry.yaml)
claims delete --xr
| Flag | Description |
|---|---|
--kind, --name, --namespace |
The XR (namespace default default); kind is optional when the name is unique |
--source-path |
The XR's file instead of kind/name |
--reason |
Shown in the PR body |
--requested-by |
Shown in the PR body (default: the git user) |
--create-pr |
Commit, push delete-claim/<name> and open the PR (needs GIT_USER/GIT_TOKEN) |
--git-repo-url |
Work on a fresh clone instead of the local checkout |
--dry-run |
Show file, runs, kustomization entries, branch and title |
--merge |
With --create-pr: wait for the PR's checks, then squash-merge it (see merge). Merging starts the deletion |
Without --create-pr the files are only removed locally. --git-branch may only name delete-claim/.... In a local checkout you must be on main (the PR base): the gate accepts nothing but the claim's removal on top of it.
change: resize a VM claim or re-run its Ansible
claims change resizes a VM claim (NativeVsphereVM, NativeProxmoxVM) in an *-xrs directory. It is a thin wrapper around the fleet repository's dispatch-change-claim.yaml, the workflow behind Backstage's request-claim-change. The rules stay in hack/claim-change.py:
- cpu, memory and disk come from create-vm's size table
- a disk never shrinks
- only the size may change
claims resolves the claim, starts the workflow with the same inputs, waits for it and prints the PR change-claim/<name>, which pr-claim-change.yaml checks. Merging the PR applies the size.
claims change --name dev7-vm --size xlarge --dry-run
claims change --name dev7-vm --size xlarge --reboot evening --reason "builds run out of memory"
claims change --source-path clusters/labda/vsphere/machinery-orders-xrs/dev7.yaml --size xlarge --reboot 2026-11-05T20:00
claims change -i # pick VM, size and reboot window
Re-run a failed AnsibleRun (--run-id, --retry)
Deleting an AnsibleRun does not re-run it (crossplane-configurations#554). A new spec.ansible.runID does: Crossplane renders the AnsibleRun afresh from the current spec and EnvironmentConfig defaults, so a fixed collection is picked up, and starts a new PipelineRun <name>-ansible-<runID>. claims change opens that change as a PR change-claim/<name>, on the same path as a resize.
claims change dev7-vm --retry --dry-run # unset -> 2, a number -> +1
claims change dev7-vm --retry --reason "baseos collection fixed"
claims change dev7-vm --run-id fix-docker # a chosen id
Read the failed run's logs before merging. The merge deletes the previous PipelineRun and its TaskRun logs. claims and the PR body name the PipelineRun.
- The claim's
spec.ansible.enabledmust betrue, and the id must be new and match^[a-z0-9]([-a-z0-9]*[a-z0-9])?$. --retryon a non-numeric runID is refused: pass the next one with--run-id.- claims checks this up front and shows
current -> new, from the checkout or, without one, from GitHub at--ref. The workflow checks again againstmain. - One change per PR:
--sizeand--run-id/--retryexclude each other, and--rebootonly goes with--size. - Needs vspherevm >= v0.14.0 / proxmoxvm >= v0.20.0 on the management cluster (crossplane-configurations#555). An older XRD rejects the field, and Flux reports the apply as failed.
| Flag | Description |
|---|---|
--kind, --name, --namespace, --source-path |
The VM claim (or the argument: a name, or a path ending in .yaml). The name is looked up in the checkout, or on GitHub without one |
--size |
New size: small, medium, large or xlarge (checked by the workflow) |
--run-id, --retry |
Re-run the AnsibleRun with this spec.ansible.runID, or the next one (instead of --size) |
--reboot |
When the one-shot run applies the resize in the guest: evening (19-22 Europe/Berlin, default), now, none, or an ISO-8601 time |
--reason, --requested-by |
Shown in the PR body. --requested-by defaults to the git user, then the token's GitHub login |
--repo, --ref |
Fleet repository (default: the checkout's; without one $CLAIMS_GITHUB_REPO or stuttgart-things/stuttgart-things) and the branch the workflow runs on and the claim is read at (default main) |
--dry-run, --no-wait |
Show the inputs only; or start the workflow and return without waiting |
--merge |
Wait for the PR's checks, then squash-merge it (see merge); not with --no-wait, and not with --retry/--run-id (merging deletes the previous PipelineRun's logs: read them, then claims merge) |
When the workflow refuses the change, for example with an unknown size, a size the VM already has, or a kind it does not resize, claims prints the workflow's ::error:: lines (the failed job's annotations).
claims talks to the GitHub API directly (claims#108): the token (see below) needs permission to run workflows (actions: write) and to read the repository. The gh CLI is not required. Outside a checkout, and in a checkout whose origin is not on GitHub, the workflow runs in --repo, $CLAIMS_GITHUB_REPO or stuttgart-things/stuttgart-things.
merge: finish an order, change or deletion PR
render --create-pr, change and delete --create-pr open a PR and stop. claims merge finishes it (claims#113): it waits for the checks, squash-merges the PR and deletes its branch.
claims merge dev7 --dry-run # show the PR, its files and checks
claims merge vm-dev7 --wait # wait for the checks, ask, merge
claims merge delete-claim/dev7-vm --wait --yes # no question (CI)
claims merge 4442 # by number, or by URL
The argument can be one of these:
- a PR number or URL
- a branch:
vm-<name>,change-claim/<name>,delete-claim/<name>orclaim-<template>-<name> - a name, which claims looks up as
vm-<name>,change-claim/<name>anddelete-claim/<name>
A VM's XR name <name>-vm finds its order vm-<name> too. When a name matches several open PRs, claims lists them; name one by number or branch then.
claims shows the PR's title, branch, labels, files, the required checks and the state of the checks. Then it asks, repeating what the merge does: MERGE = BAU builds the VM, a delete-claim PR deletes the object, a change-claim PR applies the change. --yes skips the question; without a terminal --yes is required.
Checks. These are the base branch's required status checks (branch protection and rulesets). When the branch requires none, every check on the PR counts. The fleet repository's main has no branch protection today, so every check counts there. A failed check stops the merge. Without --wait, a check that still runs stops it too. --wait waits for the checks, up to --timeout (default 30m), and stops at the first failure. When the branch moves on while claims waits, claims waits for the checks of the new head. The merge itself is pinned to the head whose checks claims saw.
Guard rails. The merge is the human approval of an order, and claims does not weaken it:
- claims only merges PRs on its own branches (above), from the repository itself (no forks), into the default branch. Arbitrary PRs are refused.
- claims never bypasses branch protection. It merges only when GitHub reports the PR mergeable (
mergeable_stateclean,unstableorhas_hooks). AblockedPR (a review or a required check missing), a PR with conflicts and one that is behind are refused, even when the token could merge as an admin. - When GitHub refuses the merge, claims prints GitHub's reason. A failed check, a timeout, a refusal or a "No" at the prompt always leaves the PR open.
--merge on render, change and delete. With --merge, render --create-pr, change and delete --create-pr wait for the PR they just opened and merge it in the same call. --merge implies --wait. The flag is the confirmation, so there is no question. The same checks and guard rails apply. Because claims opened that PR itself, a --git-branch of your own is accepted too.
The token ($GIT_TOKEN, $GITHUB_TOKEN, else the gh CLI's login) needs permission to merge PRs and delete branches (contents: write, pull_requests: write). --repo defaults to the checkout's GitHub repository; outside one, it is $CLAIMS_GITHUB_REPO or stuttgart-things/stuttgart-things.
Without a checkout of the fleet repository
claims change and claims list work from any directory (claims#107). When
the current directory is not in a checkout with *-xrs directories, they read
the fleet repository straight from GitHub: one call for the tree, then the
*-xrs files in parallel. No clone needed.
cd /tmp
claims list --kind NativeProxmoxVM
claims change sbx-labul-vm --retry --dry-run # runID read from main
- Repository:
--repo(change) /--github(list), else$CLAIMS_GITHUB_REPO, elsestuttgart-things/stuttgart-things. - Token:
$GIT_TOKEN, else$GITHUB_TOKEN, else theghCLI's login (gh auth token), the same for every GitHub call claims makes. The repository is private, so there is no anonymous fallback. $GITHUB_API_URLpoints claims at another API endpoint (GitHub Enterprise).- A checkout still wins when there is one. It may be behind
mainor on another branch; thengit pullfirst, or run claims outside it. claims deletestill needs a checkout: it writes and commits the removal itself.
encrypt
Create SOPS-encrypted Kubernetes Secrets using age encryption. Fetches a template from the API, collects secret values, generates a K8s Secret YAML, encrypts it with SOPS, and optionally commits via Git PR.
claims encrypt [flags]
| Flag | Short | Description |
|---|---|---|
--api-url |
-a |
API URL (else $CLAIM_API_URL, --endpoint, the current endpoint; no localhost default) |
--endpoint |
Named endpoint from claims endpoint list (or $CLAIM_ENDPOINT) |
|
--skip-preflight |
Do not check API, login and git/GitHub credentials before starting | |
--api-token |
Bearer token for claim-machinery-api (default: $CLAIM_API_TOKEN); see API Authentication |
|
--api-oidc-token-url |
OIDC token endpoint for client credentials (default: $CLAIM_API_OIDC_TOKEN_URL) |
|
--api-oidc-client-id |
OIDC client ID (default: $CLAIM_API_OIDC_CLIENT_ID) |
|
--api-oidc-client-secret |
OIDC client secret (default: $CLAIM_API_OIDC_CLIENT_SECRET) |
|
--api-oidc-scope |
OIDC scope(s), space- or comma-separated (default: $CLAIM_API_OIDC_SCOPE) |
|
--template |
-t |
Template name to use |
--name |
Secret name | |
--namespace |
Secret namespace | |
--params-file |
-f |
YAML/JSON file with parameters |
--param |
-p |
Inline param (key=value, repeatable) |
--output-dir |
-o |
Output directory (default: .) |
--filename-pattern |
Filename pattern (default: {{.name}}-secret.enc.yaml) |
|
--dry-run |
Show encrypted output without writing files | |
--interactive |
-i |
Force interactive mode |
--non-interactive |
Force non-interactive mode | |
--git-branch |
Branch to use/create | |
--git-create-branch |
Create the branch if it doesn't exist | |
--git-message |
Commit message (default: auto-generated) | |
--git-remote |
Git remote name (default: origin) |
|
--git-repo-url |
Clone from URL instead of using local repo | |
--git-user |
Git username (or $GIT_USER/$GITHUB_USER env) |
|
--git-token |
Git token (or $GIT_TOKEN/$GITHUB_TOKEN env) |
|
--create-pr |
Create a pull request after push | |
--pr-title |
PR title (default: auto-generated) | |
--pr-description |
PR description | |
--pr-labels |
PR labels (comma-separated) | |
--pr-base |
Base branch for PR (default: main) |
Prerequisites:
- sops CLI installed
SOPS_AGE_RECIPIENTSenvironment variable set (age public key)
Examples:
# Interactive mode (prompts for template, secret name, values)
claims encrypt
# Non-interactive with inline params
claims encrypt --non-interactive \
--template my-secret-template \
--name my-app-secret \
--namespace production \
--param username=admin \
--param password=s3cret
# Non-interactive with params file
claims encrypt --non-interactive \
--template my-secret-template \
--name db-credentials \
--namespace default \
-f examples/encrypt-params.yaml \
-o ./secrets
# Dry run (preview without writing)
claims encrypt --non-interactive \
--template my-secret-template \
--name my-app-secret \
--namespace default \
--param key=value \
--dry-run
# Encrypt and create PR
claims encrypt --non-interactive \
--template my-secret-template \
--name staging-secrets \
--namespace staging \
--param db_password=secret123 \
--create-pr --git-create-branch --git-branch feat/add-staging-secrets \
--pr-labels "secrets,automated"
Interactive Workflow
The claims render command follows an interactive workflow:
- API URL - Confirm or change the API endpoint
- Template Selection - Multi-select templates to render (space to select, enter to confirm)
- Parameter Input - Fill in parameters for each selected template, in
the template's order. With parameter conditions (claim-machinery-api#135)
the form only asks what applies: a parameter with
showWhenappears only when the earlier answers match (its value is not sent otherwise), a select withenumWhenoffers only the values the earlier answers allow (keeping the current one if allowed, else the first allowed), and every field is checked (required, enum, pattern) before the form can be submitted. Field errors of an API400are shown next to the fields when you edit. See docs/12-conditional-form.md. - Render - Call the API to generate YAML
- Review - Preview rendered resources with options to:
- Continue to save
- Show full YAML (through
$PAGER, defaultless -FRX; or start with--full) - Edit a template's parameters (re-renders after editing)
- Cancel the operation
- Output - Configure where and how to save files. When every rendered
document names its file (
stuttgart-things.com/source-path/target-path), the cwd is in a git repository and no template defines secrets, the first, preselected choice is Fleet repo by source-path: the same layout as--layout source-path(files at their annotated paths, kustomization entries, no registry entry, branch/PR title like the Backstage templates), either with commit, push and PR or as files only. Otherwise (or with Local) the directory picker starts in the directory of the order'ssource-pathannotation when there is one. - Git Operations - Optionally commit/push rendered files:
- None (just save locally)
- Commit to current branch
- Commit to new branch
- Commit and push to remote
- Commit, push & create PR (with PR details form)
Ctrl+C / Esc aborts with Aborted, nothing written. and exit code 130. After
rendering, the abort offers to print the YAML or save it to a temp file first.
Configuration
| Environment Variable | Description | Default |
|---|---|---|
CLAIM_API_URL |
API base URL (colon-separated for multiple endpoints); wins over CLAIM_ENDPOINT |
- (current endpoint; no localhost default) |
CLAIM_ENDPOINT |
Named endpoint to use (like --endpoint) |
current endpoint |
CLAIMS_CONFIG_FILE |
Endpoint config file | ~/.config/claims/config.yaml |
CLAIM_API_TOKEN |
Static bearer token for claim-machinery-api (wins over client credentials) | - (no auth) |
CLAIM_API_OIDC_TOKEN_URL |
OIDC token endpoint for client-credentials auth | - |
CLAIM_API_OIDC_CLIENT_ID |
OIDC client ID for client-credentials auth | - |
CLAIM_API_OIDC_CLIENT_SECRET |
OIDC client secret for client-credentials auth | - |
CLAIM_API_OIDC_SCOPE |
OIDC scope(s), space- or comma-separated (optional) | - |
GIT_USER |
Git username for push operations (optional with a token) | - |
GIT_TOKEN |
Git token/password for push operations | - |
GITHUB_TOKEN |
GitHub token (fallback for GIT_TOKEN; else gh auth token) |
- |
CLAIMS_REPO |
Fleet repository root for claims list |
git root of the cwd |
CLAIMS_REGISTRY |
registry.yaml for claims list |
<repo>/claims/registry.yaml |
NO_COLOR |
No banner (the banner is also left out when stdout is not a terminal) | - |
SOPS_AGE_RECIPIENTS |
age public key for SOPS encryption (required for encrypt) |
- |
Available Tasks
task --list
| Task | Description |
|---|---|
task build |
Build the binary (Dagger) |
task build-local |
go build to ./bin/claims with version, commit and date via ldflags |
task install-local |
Unit tests, build-local, install to ~/.local/bin |
task render |
Run render in non-interactive mode with params file |
task render-inline |
Run render in non-interactive mode with inline params |
task test-gitops |
Run GitOps integration tests |
task release-check |
Dry-run GoReleaser (releases come from the Release workflow only) |
task trigger-release |
Start the Release workflow by hand (no test gate) |
Testing non-interactive mode:
# With params file (default: tests/params.yaml)
task render
# With custom params file
task render PARAMS_FILE=my-params.yaml
# With inline template and params
task render-inline TEMPLATE=vspherevm PARAMS=name=test
# With multiple params
task render-inline TEMPLATE=vspherevm PARAMS="name=test,cpu=4"
Testing
Run all unit tests:
go test ./...
Run tests with verbose output:
go test ./... -v
Run integration tests (requires CLAIM_API_URL to be set):
CLAIM_API_URL=http://localhost:8080 go test -tags=integration ./tests/integration/...
Run GitOps shell tests:
./tests/test_gitops.sh
# or via task
task test-gitops
Test Coverage
| Package | Description |
|---|---|
cmd/ |
Output logic, review functionality |
internal/templates/ |
API client with mocked HTTP server |
internal/apiauth/ |
Bearer-token / client-credentials auth against a fake token endpoint |
internal/gitops/ |
Git operations, branch management, auth |
internal/params/ |
Parameter file parsing, inline params |
internal/sops/ |
SOPS encryption, K8s Secret YAML generation |
internal/registry/ |
Registry CRUD operations |
tests/integration/ |
End-to-end render workflow tests |
Project Structure
.
├── main.go # Application entry point
├── cmd/
│ ├── root.go # Root command setup
│ ├── render.go # Render command and flags
│ ├── render_interactive.go # Interactive form-based rendering
│ ├── render_form.go # Parameter form: showWhen/enumWhen, validation, terminal sizing
│ ├── render_noninteractive.go # Non-interactive mode for CI/CD
│ ├── render_review.go # Review/preview step before saving
│ ├── render_output.go # File output logic (separate/single file, dry-run)
│ ├── render_output_test.go # Output logic tests
│ ├── render_review_test.go # Review functionality tests
│ ├── render_git.go # Git operations integration
│ ├── render_pr.go # Pull request creation integration
│ ├── render_types.go # Type definitions for render config/results
│ ├── delete.go # Delete command and flags
│ ├── delete_interactive.go # Interactive delete flow
│ ├── delete_noninteractive.go # Non-interactive delete
│ ├── delete_git.go # Git operations for delete
│ ├── delete_types.go # Delete type definitions
│ ├── delete_xr.go # XR deletion in *-xrs directories (delete-claim/<name> PR)
│ ├── apiauth.go # Shared --api-token / --api-oidc-* flags, API client factory
│ ├── encrypt.go # Encrypt command and flags
│ ├── encrypt_interactive.go # Interactive encrypt flow (SOPS)
│ ├── encrypt_noninteractive.go # Non-interactive encrypt
│ ├── encrypt_git.go # Git operations for encrypt
│ ├── encrypt_types.go # Encrypt type definitions
│ ├── list.go # List command
│ ├── version.go # Version command
│ └── logo.go # ASCII logo rendering
├── internal/
│ ├── templates/
│ │ ├── types.go # API data models
│ │ ├── client.go # HTTP client for claim-machinery API
│ │ └── client_test.go # Client unit tests
│ ├── apiauth/
│ │ ├── apiauth.go # Optional bearer-token / OIDC client-credentials auth
│ │ └── apiauth_test.go # Auth tests (fake token endpoint)
│ ├── gitops/
│ │ ├── operations.go # Git operations (clone, add, commit, push)
│ │ ├── operations_test.go # Git operations tests
│ │ ├── branch.go # Branch management
│ │ ├── branch_test.go # Branch management tests
│ │ ├── auth.go # Credential resolution
│ │ ├── auth_test.go # Auth tests
│ │ ├── pr.go # Pull request creation via the GitHub API (go-github)
│ │ └── pr_test.go # PR creation tests
│ ├── sops/
│ │ ├── sops.go # SOPS binary interaction (check, encrypt)
│ │ ├── secret.go # K8s Secret YAML generation
│ │ └── sops_test.go # SOPS unit tests
│ ├── registry/
│ │ ├── registry.go # Registry CRUD operations
│ │ └── types.go # Registry type definitions
│ ├── kustomize/
│ │ └── kustomize.go # Kustomization.yaml operations
│ └── params/
│ ├── types.go # Parameter types
│ ├── file.go # File parsing logic
│ └── file_test.go # Parameter parsing tests
├── tests/
│ ├── params.yaml # Example params file for testing
│ ├── test_gitops.sh # GitOps integration tests (shell)
│ └── integration/
│ └── render_test.go # End-to-end integration tests
├── examples/
│ ├── basic-params.yaml # Basic single-template example
│ ├── multi-template.yaml # Multi-template batch rendering
│ └── gitops-workflow.yaml # GitOps workflow example
├── docs/ # Detailed documentation
├── go.mod # Go module definition
├── Taskfile.yaml # Task automation
├── catalog-info.yaml # Backstage component definition
└── README.md # This file
License
See LICENSE for details.
Author
patrick hermann
Documentation
¶
There is no documentation for this package.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
apiauth
Package apiauth provides optional bearer-token authentication for calls to claim-machinery-api.
|
Package apiauth provides optional bearer-token authentication for calls to claim-machinery-api. |
|
buildinfo
Package buildinfo resolves the version, commit and build date of the binary: from the -ldflags -X values the release builds set, falling back to the module and VCS data the Go toolchain embeds (debug.ReadBuildInfo), so a plain `go build` or `go run` still reports something useful.
|
Package buildinfo resolves the version, commit and build date of the binary: from the -ldflags -X values the release builds set, falling back to the module and VCS data the Go toolchain embeds (debug.ReadBuildInfo), so a plain `go build` or `go run` still reports something useful. |
|
conditions
Package conditions evaluates the parameter conditions of a ClaimTemplate (showWhen, enumWhen; claim-machinery-api#135) exactly as the API does (claim-machinery-api internal/claimtemplate/conditions.go), so the CLI can hide what does not apply, offer only the allowed values and drop what the API would ignore anyway.
|
Package conditions evaluates the parameter conditions of a ClaimTemplate (showWhen, enumWhen; claim-machinery-api#135) exactly as the API does (claim-machinery-api internal/claimtemplate/conditions.go), so the CLI can hide what does not apply, offer only the allowed values and drop what the API would ignore anyway. |
|
endpoint
Package endpoint keeps the named claim-machinery-api endpoints of ~/.config/claims/config.yaml (claims#116), like the contexts of a kubeconfig: one per lab, each with its URL and the ZITADEL `claims login` uses for it.
|
Package endpoint keeps the named claim-machinery-api endpoints of ~/.config/claims/config.yaml (claims#116), like the contexts of a kubeconfig: one per lab, each with its URL and the ZITADEL `claims login` uses for it. |
|
ghclient
Package ghclient builds the go-github client claims talks to GitHub with (claims#108): the token, the API endpoint and errors that say what to do.
|
Package ghclient builds the go-github client claims talks to GitHub with (claims#108): the token, the API endpoint and errors that say what to do. |
|
ghfs
Package ghfs is a read-only fs.FS over one ref of a GitHub repository, so claims can read the fleet repository without a local checkout (claims#107).
|
Package ghfs is a read-only fs.FS over one ref of a GitHub repository, so claims can read the fleet repository without a local checkout (claims#107). |
|
layout
Package layout places the documents of a rendered order into a GitOps repository by the paths the order names itself.
|
Package layout places the documents of a rendered order into a GitOps repository by the paths the order names itself. |
|
orders
Package orders is the client of machinery-order-service's REST API (docs/adr/0002-order-through-the-order-service.md): orders go through the service, which renders with the caller's token and opens the pull request with its own GitHub identity.
|
Package orders is the client of machinery-order-service's REST API (docs/adr/0002-order-through-the-order-service.md): orders go through the service, which renders with the caller's token and opens the pull request with its own GitHub identity. |
|
xrdelete
Package xrdelete is the file half of deleting a claim (an XR) from an *-xrs directory of the fleet repository, file first: remove the claim's file, the one-shot runs that apply to it and their kustomization.yaml entries, then open the pull request delete-claim/<name>.
|
Package xrdelete is the file half of deleting a claim (an XR) from an *-xrs directory of the fleet repository, file first: remove the claim's file, the one-shot runs that apply to it and their kustomization.yaml entries, then open the pull request delete-claim/<name>. |