Sub-issue of #86.
Background
Karta ships a dozen sample definitions under docs/samples/ as hand-written YAML (jobset.yaml, pytorch.yaml, raycluster.yaml, etc.). Hand-written YAML has no compile-time checking: a typo in a field path, a wrong GVK, or drift from the Karta API type is only caught at runtime, if at all. In addition, we plan to provide the our kartas that are verified as part of karta library (see #86) - having them as go struct would make it much cleaner
Proposal
Make typed Go definitions the single source of truth for the built-in samples, and generate the YAML from them.
- New
pkg/builtin/ package holding each sample as a typed *v1alpha1.Karta value, one file per workload (e.g. pkg/builtin/jobset.go, pkg/builtin/pytorch.go). The jq-expression notes currently embedded in the YAML move into Go comments. The same package indexes the definitions by workload identity and exposes the resolver API (Get / Add / List), with no go:embed.
- A generator (
make generate-builtins) that marshals every definition in pkg/builtin/ to YAML and writes it to docs/builtin/, preserving the existing filename convention {group-slug}-{kind-lowercase}-{version}.yaml.
- A CI check that runs the generator and fails on any diff, so
docs/builtin/ can never drift from pkg/builtin/. This mirrors the existing make validate pattern (git diff --exit-code).
- Suggested name in code: "catalog", in description: "Built-in catalog"
Scope
- Add
pkg/builtin/ with typed definitions equivalent to the current 13 YAML files.
- Add the resolver API (
Get / Add / List) in the same package.
- Add a generator (
cmd/gen-samples or under hack/) invoked by a new generate-samples Make target.
- Wire
generate-samples into the validate target so git diff --exit-code covers it. CI already runs make check → validate; add an explicit CI step only if clearer.
- Convert all existing samples; the hand-written YAML becomes generated output.
- Tests verify each definition is structurally valid and round-trips to the committed YAML.
Acceptance criteria
make generate-samples regenerates docs/builtin/ from pkg/builtin/.
- CI fails when
pkg/builtin/ and docs/samples/ are out of sync.
- All 13 existing samples are represented as Go structs with passing tests.
Sub-issue of #86.
Background
Karta ships a dozen sample definitions under
docs/samples/as hand-written YAML (jobset.yaml,pytorch.yaml,raycluster.yaml, etc.). Hand-written YAML has no compile-time checking: a typo in a field path, a wrong GVK, or drift from theKartaAPI type is only caught at runtime, if at all. In addition, we plan to provide the our kartas that are verified as part of karta library (see #86) - having them as go struct would make it much cleanerProposal
Make typed Go definitions the single source of truth for the built-in samples, and generate the YAML from them.
pkg/builtin/package holding each sample as a typed*v1alpha1.Kartavalue, one file per workload (e.g.pkg/builtin/jobset.go,pkg/builtin/pytorch.go). The jq-expression notes currently embedded in the YAML move into Go comments. The same package indexes the definitions by workload identity and exposes the resolver API (Get/Add/List), with nogo:embed.make generate-builtins) that marshals every definition inpkg/builtin/to YAML and writes it todocs/builtin/, preserving the existing filename convention{group-slug}-{kind-lowercase}-{version}.yaml.docs/builtin/can never drift frompkg/builtin/. This mirrors the existingmake validatepattern (git diff --exit-code).Scope
pkg/builtin/with typed definitions equivalent to the current 13 YAML files.Get/Add/List) in the same package.cmd/gen-samplesor underhack/) invoked by a newgenerate-samplesMake target.generate-samplesinto thevalidatetarget sogit diff --exit-codecovers it. CI already runsmake check→validate; add an explicit CI step only if clearer.Acceptance criteria
make generate-samplesregeneratesdocs/builtin/frompkg/builtin/.pkg/builtin/anddocs/samples/are out of sync.