Tiny helper that turns comment-annotated values.yaml
files into:
- Go structs – strongly typed, IDE-friendly.
- CustomResourceDefinitions (CRD) – produced by
controller-gen
. - values.schema.json – OpenAPI schema extracted from the CRD.
- README.md – auto-updated
## Parameters
section.
The chain “structs → CRD → OpenAPI” re-uses the same code that Kubernetes itself relies on, so you get maximum type compatibility for free.
graph LR
A[values.yaml] --> B(Go structs)
B --> C[CRD YAML]
C --> D[values.schema.json]
A --> E[README.md]
- Annotate your
values.yaml
(see examples for the exact syntax). - Run cozyvalues-gen; it parses the comments and spits out Go code.
- controller-gen compiles that code, emitting a CRD.
- The tool trims the CRD down to a Helm-compatible schema.
cozyvalues-gen \
--values values.yaml \
--schema values.schema.json
See cozyvalues-gen
-h for all flags.
- Go toolchain must be installed and accessible via
$PATH
.
go install github.com/cozystack/cozyvalues-gen@latest
The binary lands in $(go env GOPATH)/bin
(usually ~/go/bin
). Make sure that directory is on your $PATH
.
Head over to https://github.com/cozystack/cozyvalues-gen/releases, grab the archive for your OS/arch, unpack it somewhere on your $PATH
.
Annotation token | Go type | JSON Schema | Examples |
---|---|---|---|
string |
string |
string | "hello" |
bool |
bool |
boolean | true |
int , int32 , int64 |
matching signed integer | number | 42 |
float32 , float64 |
matching float | number | 3.14 |
quantity |
resource.Quantity |
string | "500Mi" , "100m" , "4Gi" |
duration |
metav1.Duration |
string | "5m" , "1h30m" |
time |
metav1.Time |
string (RFC 3339) | "2025-08-07T12:00:00Z" |
object |
k8sRuntime.RawExtension |
any JSON/YAML | {"aaa": 123, "foo": "bar"} |
emptyobject |
empty struct (struct{} ) – no fields |
{} |
{} |
*<primitive> |
pointer to that primitive (nil allowed) |
primitive or null |
"asd" , null … |
<CustomType> |
generated struct | object | declared from @field annotations |
*<CustomType> |
pointer to generated struct | object or null |
null |
[]<T> |
slice / YAML sequence | list | []string , []*int , []CustomType |
map[string]<T> |
map / YAML mapping | object | keys are always strings |
These tokens map to a plain string
field, plus format: "<alias>"
in the OpenAPI schema:
format |
Example value |
---|---|
bsonobjectid |
507f1f77bcf86cd799439011 |
uri |
https://grafana.example.com |
email |
user@example.com |
hostname |
db.internal |
ipv4 |
192.168.0.10 |
ipv6 |
2001:db8::1 |
cidr |
10.0.0.0/24 |
mac |
00:1A:2B:3C:4D:5E |
uuid , uuid3 , uuid4 , uuid5 |
550e8400-e29b-41d4-a716-446655440000 |
isbn , isbn10 , isbn13 |
9783161484100 |
creditcard |
4242 4242 4242 4242 |
ssn |
123-45-6789 |
hexcolor |
#ff8800 |
rgbcolor |
rgb(255,136,0) |
byte |
SGVsbG8= (base64) |
password |
(hidden by most UIs) |
date |
2025-08-07 |
Tip: use any alias exactly like a regular type, e.g.
## @param apiURL {uri} External URL of the API apiURL: ""
Created for the Cozystack project. 🚀