Overview
defkit is a Go SDK that lets platform engineers author KubeVela X-Definitions — ComponentDefinition, TraitDefinition, PolicyDefinition, WorkflowStepDefinition — using native Go code. The Go code compiles to CUE transparently: you never need to write or see CUE.
The Problem
KubeVela's extension system (X-Definitions) is the primary way platform teams build reusable abstractions — defining how workloads run, how traits modify them, and how policies govern delivery. Today, authoring these definitions requires writing CUE, a specialized configuration language. This creates several friction points:
- Language barrier — Platform engineers must learn CUE, a niche language with limited community resources. Most teams are already proficient in Go.
- Poor IDE experience — CUE tooling lacks full autocompletion, inline documentation, and refactoring support that Go developers expect.
- Late error detection — CUE schema and template errors only surface at deployment time, not at authoring time. A typo in a CUE definition can pass through CI and fail in production.
- No standard distribution — There is no
go getequivalent for CUE definitions. Teams share definitions by copying files or maintaining internal registries. - Difficult to test — Unit testing CUE templates requires a running KubeVela cluster or custom evaluation harnesses. There is no native
go teststory.
The Solution
defkit eliminates these friction points by providing a fluent Go API that compiles to CUE behind the scenes. Platform engineers write standard Go — with full IDE support, compile-time type checking, and go test — and defkit transparently generates the CUE that the KubeVela controller expects. The output is identical to hand-written CUE; the authoring experience is entirely Go.
Benefits
- Type Safety — Catch configuration errors at Go compile time, not at Kubernetes deploy time. Full type inference for all parameter types.
- IDE Support — Full autocompletion, inline documentation, and refactoring in any Go IDE. No CUE plugin required.
- Testable — Unit-test definitions with standard
go testand Gomega matchers. No cluster needed for unit tests. - Distributable — Share definitions as standard Go packages via
go get. Version-controlled alongside your platform code. - CUE Compatible — Produces the same CUE output consumed by the KubeVela controller. Mix Go-authored and CUE-authored definitions freely.
- Fluent API — Method-chaining builder pattern makes definitions readable and concise. No YAML, no CUE schema wrestling.
Your definitions have complex conditional logic, your team is already Go-proficient, or you need to unit-test and distribute definitions as packages.
You're writing simple definitions with few parameters or doing quick one-off experiments where minimal setup matters.
Both approaches produce identical output — the KubeVela controller sees no difference. You can mix Go-authored and CUE-authored definitions in the same cluster.