feat: Support Kraftfile v0.7 templates and OCI runtime refs#2771
feat: Support Kraftfile v0.7 templates and OCI runtime refs#2771ijaidev wants to merge 2 commits intounikraft:stagingfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds end-to-end Kraftfile v0.7 support by dispatching project loading based on spec version, resolving templates prior to project construction, preserving full OCI runtime references, and carrying v0.7 filesystem metadata (rootfs/ROM) through build/package flows.
Changes:
- Add spec sniffing + loader dispatch and implement a dedicated v0.7 project loader (incl. template pre-merge).
- Preserve full OCI runtime references via new runtime query/reference helpers and update runtime lookups accordingly.
- Plumb v0.7 filesystem descriptors/types through targets, initrd, packaging, and CLI flows (rootfs type + ROM descriptors).
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| unikraft/type.go | Adds shared project-name normalization helper. |
| unikraft/target/target.go | Normalizes target artifact names; switches ROMs to FS descriptors. |
| unikraft/runtime/transform.go | Updates schema transform to preserve full OCI refs. |
| unikraft/runtime/runtime.go | Adds runtime query/reference helpers + improved name/version splitting. |
| unikraft/runtime/runtime_test.go | Adds tests for runtime ref parsing and schema transform. |
| unikraft/app/volume/transform.go | Adds support for volumes.mode. |
| unikraft/app/template_resolver.go | Introduces v0.7 template resolution & merge before project construction. |
| unikraft/app/project.go | Refactors legacy loader path and records loader/spec metadata. |
| unikraft/app/project_v07.go | Implements v0.7 loader mapping Kraftfile fields into the app model. |
| unikraft/app/project_v07_test.go | Adds tests for spec dispatch, naming, outdir, runtime refs, volumes, etc. |
| unikraft/app/project_loader.go | Adds spec sniffing + dispatch entrypoint for project creation. |
| unikraft/app/normalize.go | Reuses shared name normalization helper. |
| unikraft/app/loader.go | Updates legacy application parsing to new fs type / ROM descriptor types. |
| unikraft/app/loader_kind.go | Introduces loader kind constants and mutation-not-supported error. |
| unikraft/app/application.go | Records loader/spec version, blocks mutation for non-legacy, updates ROM/fsType types. |
| unikraft/app/application_options.go | Adds options to record loader/spec; switches ROM/fsType option types. |
| packmanager/pack_options.go | Switches ROMs to FS descriptors in pack options. |
| oci/pack.go | Switches ROM handling to FS descriptors for OCI packaging. |
| internal/cli/kraft/run/runner_kraftfile_runtime.go | Uses runtime query/reference helpers when resolving runtimes. |
| internal/cli/kraft/run/run.go | Switches rootfs-type flag plumbing to v0.7 fs type enum. |
| internal/cli/kraft/pkg/pkg.go | Switches pkg rootfs/ROM options to v0.7 fs/FS types. |
| internal/cli/kraft/pkg/packager_kraftfile_runtime.go | Updates packaging flow to pass FS ROM descriptors into initrd ROM builder. |
| internal/cli/kraft/cloud/deploy/deploy.go | Switches rootfs-type handling to v0.7 fs type enum. |
| internal/cli/kraft/cloud/compose/up/up.go | Switches rootfs-type handling to v0.7 fs type enum. |
| internal/cli/kraft/cloud/compose/build/build.go | Switches rootfs-type handling to v0.7 fs type enum. |
| internal/cli/kraft/build/builder_kraftfile_runtime.go | Uses runtime query/reference helpers and improves runtime search messaging. |
| internal/cli/kraft/build/build.go | Writes initrd artifacts to project outdir and switches rootfs-type enum type. |
| initrd/rootfs.go | Changes ROM builder to accept FS descriptors and build format-aware ROM images. |
| initrd/options.go | Switches initrd fs type to use kraftfile v0.7 enum and updates helpers/constants. |
| initrd/file.go | Updates fs type detection to return v0.7 fs type enum. |
| go.mod | Adds new dependencies for kraftfile v0.7 support + yaml. |
| go.sum | Updates checksums for new/updated dependencies. |
Comments suppressed due to low confidence (1)
initrd/rootfs.go:134
- ROM output paths are hard-coded to
filepath.Join(workdir, unikraft.BuildDir, ...). For projects that set a custom output directory (especially v0.7 where artifacts are expected to land in the configuredBUILD_DIR), this will write ROM artifacts to a different location. Consider deriving the output base fromunikraft.FromContext(ctx).BUILD_DIR(when set) or adding an explicit output-dir parameter.
WithOutput(filepath.Join(
workdir,
unikraft.BuildDir,
fmt.Sprintf("rom%d-%s.%s", i+1, arch, fsType),
)),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| value["destination"] = doc.Destination | ||
| } | ||
| if doc.Mode != nil { | ||
| value["mode"] = doc.Mode |
There was a problem hiding this comment.
doc.Mode is passed through as-is, but volume.TransformFromSchema expects the mode property to be a string. If doc.Mode is an optional/pointer type (as implied by the nil-check), this will fail at runtime. Pass the dereferenced string value instead (and keep omitting the key when unset).
| value["mode"] = doc.Mode | |
| value["mode"] = *doc.Mode |
There was a problem hiding this comment.
doc.Mode is not a pointer, so it can't be dereferenced. volume.TransformFromSchema will throw an error if it can't be converted into a string.
6f829a3 to
f0f8cc1
Compare
|
@craciunoiuc I made some changes as asked by Copilot Somehow, CI tests are not triggered |
f0f8cc1 to
632034a
Compare
|
Also the PR is quite lengthy, can you split it into more commits so it's easier to go through? |
Dispatch project loading by Kraftfile spec version and map v0.7 documents into the existing application model. Keep v0.7 projects read-only for now and cover loader selection, component parsing, runtime/template/rootfs mapping, volume mode handling, and mutation rejection. Signed-off-by: Jaidev <himjaidev@gmail.com>
632034a to
cfc1f63
Compare
some files are dependent on each other and require changes simultaneously. But I'm trying to figure out how I can organise this in small commits |
cfc1f63 to
e54bccc
Compare
Resolve v0.7 templates before loading projects so template\ndefaults merge correctly and project fields still take precedence.\n\nPreserve full OCI runtime references, carry FS metadata for\nrootfs and ROMs, and reuse the project output directory across\nbuild, pkg, and deploy flows. Signed-off-by: Jaidev <himjaidev@gmail.com>
e54bccc to
763c961
Compare
|
Yup, go ahead, create a separate commit for it though |
|
Created another PR with smaller commits |


PR Title
feat: add Kraftfile v0.7 project loading, template resolution, and OCI runtime ref support
Description of changes
This PR adds end-to-end support for Kraftfile
v0.7projects across project loading, template resolution, runtime lookup, and packaging/build flows.The first part of the change teaches project initialization to dispatch by Kraftfile spec version and introduces a dedicated
v0.7loader built onunikraft.com/x/kraftfile. The new loader mapsv0.7documents into the existing application model, records the loader/spec version on the project, supports parsing unikraft/runtime/library/target/rootfs/rom/volume fields, preserves project naming semantics from the source document, normalizes target artifact names, and keepsv0.7projects read-only by rejecting legacy mutation paths such asSave,AddLibrary, andRemoveLibrary.The second part resolves
v0.7templates before project construction so template defaults are merged first and project values still take precedence. It also preserves full OCI runtime references instead of incorrectly splitting registry-based refs into name/tag pairs, adds helper query/reference methods to runtime resolution, and updates build/run/pkg flows to use those helpers consistently when searching for runtime packages.Root filesystem and ROM handling are updated to carry filesystem metadata from the
v0.7schema through initrd and OCI packaging paths. ROM inputs now travel as structured filesystem descriptors instead of bare strings, allowing format-aware packaging while still reusing the existing initrd build pipeline. The build, run, pkg, compose, and deploy commands also switch their rootfs-type handling to thev0.7filesystem enum and reuse the project output directory so artifacts land in the configured build location.The change is covered with focused tests for spec sniffing, loader dispatch, project naming/outdir behavior, component parsing, runtime reference preservation, rootfs format handling, volume mapping, and runtime OCI parsing.
Validation
make fmtpassedNote