crossplane-cuefn

module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0, MIT

README

crossplane-cuefn

Define a Crossplane platform API as a single CUE module — its schema and the Kubernetes resources it renders — and crossplane-cuefn gives you both halves of running it:

  • the cuefn CLI generates the XRD and packages an installable Crossplane Configuration from that module, and
  • a Crossplane v2 composition function pulls the same module from an OCI registry at runtime and renders your resources against each composite resource (XR).

One source of truth, in CUE, for both the API you install and the resources it produces — no Go, no patch-and-transform pipelines.

Status: early development. Every surface works end to end and is covered by CI, but expect them to change.

Install

Homebrew (macOS/Linux):

brew install meigma/tap/cuefn

Scoop (Windows):

scoop bucket add meigma https://github.com/meigma/scoop-bucket && scoop install meigma/cuefn

mise (installs from GitHub releases, verifying their attestations):

mise use -g "github:meigma/crossplane-cuefn[bin=cuefn]"

Nix:

nix profile install github:meigma/crossplane-cuefn

Shell (Linux/macOS — verifies checksums, and SLSA provenance when gh is present):

curl -fsSL https://raw.githubusercontent.com/meigma/crossplane-cuefn/master/install.sh | bash

Go:

go install github.com/meigma/crossplane-cuefn/cmd/cuefn@latest

See installing the CLI for prebuilt archives and provenance verification. The composition function is published as a signed Crossplane Function package at ghcr.io/meigma/function-cuefn, which Crossplane pulls automatically when you install a generated Configuration.

Example

One module is the whole platform API — the schema and the transform that renders its resources:

// app.cue
package app

// #API and #Spec are the API: its identity, and a closed, defaulted spec schema.
#API: {
	group:   "platform.example.com"
	version: "v1alpha1"
	kind:    "XApp"
	plural:  "xapps"
}
#Spec: {
	image:    string
	replicas: *1 | int & >=1 & <=10 // defaults to 1, bounded 1–10
}

// out.* is the transform: the engine fills `out.input` from each XR, and reads
// back the resources you return.
out: {
	input: {
		spec: #Spec
		metadata: name: string | *"app"
	}
	resources: deployment: object: {
		apiVersion: "apps/v1"
		kind:       "Deployment"
		metadata: name: input.metadata.name
		spec: {
			replicas: input.spec.replicas
			selector: matchLabels: app: input.metadata.name
			template: {
				metadata: labels: app: input.metadata.name
				spec: containers: [{name: "app", image: input.spec.image}]
			}
		}
	}
}

Render it against an XR locally — no cluster, no registry:

cuefn render example.com/app@v0 --dir . --xr xr.yaml

Then package it as an installable Configuration — the XRD, a Composition wired to the function, and the function as a dependency — in one command:

cuefn publish example.com/app@v0.1.0 \
  --dir . --publish-module \
  --metadata org.opencontainers.image.source=https://github.com/example/platform-modules \
  --package registry.example.com/xapp:v0.1.0

kubectl apply that package as a Crossplane Configuration and the XApp API is live on your cluster. The Quickstart walks the whole loop — module to a running XR — step by step.

Commands

Command What it does
cuefn render Render a module against an XR locally — no cluster.
cuefn check Run the module's static health checks (fmt, vet, XRD golden).
cuefn test Run the module's declarative test cases (tests/*.txtar).
cuefn generate Emit the structural XRD from the module's schema.
cuefn validate Check an XR's spec against the module's schema before apply.
cuefn publish Publish a module and package its installable Crossplane Configuration.
cuefn publish-function Package the composition function as a Crossplane Function.
cuefn function Serve the composition function over gRPC (the runtime).

See the CLI reference for every flag.

Documentation

Full documentation: https://meigma.github.io/crossplane-cuefn

  • Quickstart — write a module, publish it, install a Configuration, and watch an XR render.
  • How-to guides — one task at a time: render locally, generate an XRD, validate, publish, serve the function, and configure the runtime.
  • Reference — the module contract, the CLI, configuration & environment, and the Input CRD.
  • Explanation — the design: one module / two outputs, the digest lock-step, and the lean runtime image.

Contributing

See CONTRIBUTING.md for local setup, the toolchain, and the release process. Security issues go through SECURITY.md.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option (SPDX: Apache-2.0 OR MIT). Unless you state otherwise, any contribution you submit for inclusion in this project shall be dual licensed as above, without any additional terms or conditions.

Directories

Path Synopsis
cmd
cuefn command
input
v1beta1
Package v1beta1 contains the Input type for the cuefn composition function.
Package v1beta1 contains the Input type for the cuefn composition function.
internal
check
Package check is the static module-health core behind `cuefn check`: it verifies canonical CUE formatting, that the module evaluates cleanly without requiring concreteness (the programmatic `cue vet -c=false ./...`), and that the module's XRD generates — optionally comparing it against a reviewed golden file.
Package check is the static module-health core behind `cuefn check`: it verifies canonical CUE formatting, that the module evaluates cleanly without requiring concreteness (the programmatic `cue vet -c=false ./...`), and that the module's XRD generates — optionally comparing it against a reviewed golden file.
cli
contract
Package contract holds the Go-side validation for the shipped CUE contract module (the repo's top-level contract/ directory).
Package contract holds the Go-side validation for the shipped CUE contract module (the repo's top-level contract/ directory).
cueerr
Package cueerr formats CUE evaluation errors into concise, deduplicated messages.
Package cueerr formats CUE evaluation errors into concise, deduplicated messages.
function
Package function is the Crossplane v2 composition-function edge adapter for cuefn.
Package function is the Crossplane v2 composition-function edge adapter for cuefn.
modulepublish
Package modulepublish prepares and publishes canonical CUE module OCI artifacts.
Package modulepublish prepares and publishes canonical CUE module OCI artifacts.
pkg
Package pkg assembles an installable Crossplane Configuration xpkg image from the YAML a single CUE module generates, and pushes it to an OCI registry.
Package pkg assembles an installable Crossplane Configuration xpkg image from the YAML a single CUE module generates, and pushes it to an OCI registry.
render
Package render evaluates a CUE module from a local directory against a curated set of inputs and returns the Kubernetes resources, readiness, and status it produces.
Package render evaluates a CUE module from a local directory against a curated set of inputs and returns the Kubernetes resources, readiness, and status it produces.
schema
Package schema is the author-time codegen core: it turns an already-built CUE module value into a Kubernetes-structural Crossplane v2 XRD, and validates a populated XR spec against the module's #Spec.
Package schema is the author-time codegen core: it turns an already-built CUE module value into a Kubernetes-structural Crossplane v2 XRD, and validates a populated XR spec against the module's #Spec.
snapshot
Package snapshot loads the YAML fixtures cuefn accepts as render inputs — XRs, environments, and required/observed cluster-object snapshots — and matches required resources against a module's emitted requirements the way Crossplane delivers them.
Package snapshot loads the YAML fixtures cuefn accepts as render inputs — XRs, environments, and required/observed cluster-object snapshots — and matches required resources against a module's emitted requirements the way Crossplane delivers them.
test/common
Package common holds the shared test infrastructure for the relocated integration and end-to-end suites: a throwaway OCI registry, environment gates, path/port helpers, binary/gRPC serving helpers, synthetic runtime bases, stream parsing, render-result accessors, and typed Crossplane fixtures.
Package common holds the shared test infrastructure for the relocated integration and end-to-end suites: a throwaway OCI registry, environment gates, path/port helpers, binary/gRPC serving helpers, synthetic runtime bases, stream parsing, render-result accessors, and typed Crossplane fixtures.
test/e2e
Package e2e is the edge adapter for the kind-based end-to-end harness.
Package e2e is the edge adapter for the kind-based end-to-end harness.
testharness
Package testharness is the core of `cuefn test`: it parses txtar test cases for cuefn modules, renders them through the real engine, and evaluates the declared expectations against a normalized result document.
Package testharness is the core of `cuefn test`: it parses txtar test cases for cuefn modules, renders them through the real engine, and evaluates the declared expectations against a normalized result document.
textdiff
Package textdiff renders plain line diffs of small, human-reviewed texts such as golden files.
Package textdiff renders plain line diffs of small, human-reviewed texts such as golden files.

Jump to

Keyboard shortcuts

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