Documentation
¶
Overview ¶
Package v1 implements the v1 HTTP API for the sandbox daemon.
All v1 routes are registered under PathPrefix ("/v1") via RegisterRoutes. The package owns its wire contract: handlers in this package are the only code allowed to decode request bodies or shape response bodies for v1.
Versioning rules (soft freeze, see pr-review.md):
- Behavioral changes to v1 wire bodies, status codes, or paths are forbidden once shipped. Add a new version package (pkg/api/vN) instead.
- Bug and security fixes that preserve wire compatibility are allowed.
The service layer (internal/service) stays version-agnostic. v1 handlers translate v1 DTOs ↔ models.* and call into the shared service.
Index ¶
Constants ¶
const PathPrefix = "/v1"
PathPrefix is the URL prefix every v1 route is registered under. Keep this in sync with the v1 SDK clients (each SDK pins the same prefix in its internal/api/v1 module).
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
RegisterRoutes mounts every v1 route onto mux. Paths are written with the PathPrefix already baked in so this file is the single grep target for "what does v1 expose?".
Types ¶
type BuildConfig ¶
BuildConfig mirrors the operator-configured image-build knobs.
type Deps ¶
type Deps struct {
Service *service.Service
Logger *slog.Logger
// Auth wraps each handler with bearer-token auth. The middleware lives in
// pkg/api so all versions share one auth contract; the version package
// only decides which routes need it.
Auth func(http.Handler) http.Handler
// Builder is optional. When nil, POST /v1/images/build responds 503.
Builder ImageBuilder
Build BuildConfig
// ContainerEngine is the host engine (docker|containerd). Used for
// Server-Timing engine tags and BuildKit-absent clear errors.
ContainerEngine string
}
Deps holds the shared dependencies a version package needs from the top-level pkg/api router. Keeping these explicit (rather than reaching into pkg/api globals) lets future version packages coexist without coupling.
type ImageBuilder ¶
type ImageBuilder interface {
BuildImage(ctx context.Context, req docker.BuildImageRequest) error
ImageExists(ctx context.Context, imageRef string) (bool, error)
PushImage(ctx context.Context, req docker.PushImageRequest) (string, error)
// RefreshTag bumps Docker's Metadata.LastTagTime so the built-image
// janitor doesn't GC a tag that was just handed out from the build
// cache. Called on the ImageExists==true short-circuit path.
RefreshTag(ctx context.Context, fullRef string) error
// RemoveImage rolls back a freshly built tag when the downstream
// snapshot-register call fails — otherwise the layer leaks because no
// snapshot row points at it for the built-image janitor to clean up.
RemoveImage(ctx context.Context, imageRef string) error
}
ImageBuilder is the slice of pkg/docker.Client v1 needs to compile an Image-builder graph into a content-addressed local image tag, and optionally push the result to a remote registry. Declared as an interface so the test harness can stub it without standing up a real Docker daemon. PushImage is v1-only — the Daytona facade interface deliberately omits it to keep its surface aligned with upstream Daytona.