feat: add builtin runtime support#4430
Conversation
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR implements a built-in runtime for curated KRM functions (apply-replacements and starlark) inside kpt itself, allowing them to run without Docker by registering them in a thread-safe in-process registry. When a function image matches a registered builtin (by normalized name, ignoring tags/digests), the builtin is used; otherwise the existing Docker/WASM fallback is preserved.
Changes:
- New self-registration registry (
internal/builtins/registry/) with thread-safeRegister/Lookupusing image name normalization - Built-in implementations for
apply-replacementsandstarlarkfunctions, wired viainit()blank imports - Integration into
fnruntime/runner.goto check the builtin registry before falling back to Docker/WASM
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
internal/builtins/registry/registry.go |
Thread-safe builtin function registry with image name normalization |
internal/builtins/applyreplacements/apply_replacements.go |
Built-in apply-replacements KRM function implementation |
internal/builtins/starlark/starlark.go |
Built-in starlark KRM function entry point |
internal/builtins/starlark/config.go |
Starlark config parser supporting StarlarkRun, Run, and ConfigMap kinds |
internal/builtins/starlark/processor.go |
Starlark processing logic |
internal/builtins/starlark/config_test.go |
Tests for starlark config parsing |
internal/builtins/BuiltinRuntime.go |
Blank-imports all builtins to trigger init() registration |
internal/fnruntime/runner.go |
Wires builtin registry lookup between pkg-context and Docker/WASM |
go.mod / go.sum |
Adds starlark catalog dependency and upgrades fn SDK to v1.0.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: Abdulrahman Fikry <abdulrahmanfikry1@gmail.com>
446b055 to
4bdb97c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Abdulrahman Fikry <abdulrahmanfikry1@gmail.com> Signed-off-by: abdulrahman11a <abdulrahmanfikry1@gmail.com>
d83136d to
267c21e
Compare
Summary
Closes #4307
This PR implements a built-in runtime for curated KRM functions inside kpt itself,
allowing
apply-replacementsandstarlarkto run without pulling images from Docker Hub.Approach
As discussed in the issue thread, this implementation avoids reintroducing a circular
dependency between Porch and kpt by moving the built-in runtime concept into kpt directly.
The architecture is intentionally simple and extensible — new functions can be added
incrementally by registering them in the builtin registry.
How it works
A thread-safe self-registration registry (
internal/builtins/registry) allows KRM functionimplementations to register themselves via
init(). Thefnruntimerunner checks thisregistry before falling back to Docker or WASM, so existing behavior is fully preserved
for unregistered functions.
Priority order in
fnruntime/runner.go:pkg-contextbuiltin (existing)Functions included
ghcr.io/kptdev/krm-functions-catalog/apply-replacementsghcr.io/kptdev/krm-functions-catalog/starlarkFiles changed
internal/builtins/registry/registry.gointernal/builtins/applyreplacements/apply_replacements.gointernal/builtins/starlark/starlark.gointernal/builtins/starlark/config.goStarlarkRunandRunkinds)internal/builtins/starlark/processor.gointernal/builtins/BuiltinRuntime.goinit()internal/fnruntime/runner.goVerified locally
Both functions execute without Docker running.

Next steps