Documentation
¶
Index ¶
- Constants
- Variables
- func CreateEmptyExt4Disk(diskPath string, sizeBytes int64) error
- func ExportRootfs(rootfsDir, outputPath string, format ExportFormat) (int64, error)
- func GetDiskPath(p *paths.Paths, imageName string, digest string) (string, error)
- func IsSystemdImage(entrypoint, cmd []string) bool
- type BuildQueue
- func (q *BuildQueue) ActiveCount() int
- func (q *BuildQueue) Enqueue(imageName string, req CreateImageRequest, startFn func()) int
- func (q *BuildQueue) GetPosition(imageName string) *int
- func (q *BuildQueue) MarkComplete(imageName string)
- func (q *BuildQueue) PendingCount() int
- func (q *BuildQueue) QueueLength() int
- type CreateImageRequest
- type ExportFormat
- type Image
- type Manager
- type ManifestInspector
- type Metrics
- type MirrorRequest
- type MirrorResult
- type NormalizedRef
- func (r *NormalizedRef) Digest() string
- func (r *NormalizedRef) DigestHex() string
- func (r *NormalizedRef) IsDigest() bool
- func (r *NormalizedRef) Repository() string
- func (r *NormalizedRef) Resolve(ctx context.Context, inspector ManifestInspector) (*ResolvedRef, error)
- func (r *NormalizedRef) String() string
- func (r *NormalizedRef) Tag() string
- type OCIClient
- func (c *OCIClient) InspectManifest(ctx context.Context, imageRef string) (string, error)
- func (c *OCIClient) InspectManifestForLinux(ctx context.Context, imageRef string) (string, error)
- func (c *OCIClient) PullAndUnpack(ctx context.Context, imageRef, digest, exportDir string) error
- func (c *OCIClient) PullAndUnpackForLinux(ctx context.Context, imageRef, digest, exportDir string) error
- type QueuedBuild
- type ResolvedRef
Constants ¶
const ( StatusPending = "pending" StatusPulling = "pulling" StatusConverting = "converting" StatusReady = "ready" StatusFailed = "failed" )
const DefaultImageFormat = FormatExt4
DefaultImageFormat is the default export format for OCI images
Variables ¶
var ( ErrNotFound = errors.New("image not found") ErrInvalidName = errors.New("invalid image name") )
Functions ¶
func CreateEmptyExt4Disk ¶
CreateEmptyExt4Disk creates a sparse disk file and formats it as ext4. Used for volumes and instance overlays that need empty writable filesystems.
func ExportRootfs ¶
func ExportRootfs(rootfsDir, outputPath string, format ExportFormat) (int64, error)
ExportRootfs exports rootfs directory in specified format (public for system manager)
func GetDiskPath ¶
GetDiskPath returns the filesystem path to an image's rootfs.erofs file (public for instances manager)
func IsSystemdImage ¶
IsSystemdImage checks if the image's CMD indicates it wants systemd as init. Detection is based on the effective command (entrypoint + cmd), not whether systemd is installed in the image.
Returns true if the image's command is:
- /sbin/init
- /lib/systemd/systemd
- /usr/lib/systemd/systemd
Types ¶
type BuildQueue ¶
type BuildQueue struct {
// contains filtered or unexported fields
}
BuildQueue manages concurrent image builds with a configurable limit
func NewBuildQueue ¶
func NewBuildQueue(maxConcurrent int) *BuildQueue
func (*BuildQueue) ActiveCount ¶
func (q *BuildQueue) ActiveCount() int
ActiveCount returns number of actively building images
func (*BuildQueue) Enqueue ¶
func (q *BuildQueue) Enqueue(imageName string, req CreateImageRequest, startFn func()) int
Enqueue adds a build to the queue. Returns queue position (0 if started immediately, >0 if queued). If the image is already building or queued, returns its current position without re-enqueueing.
func (*BuildQueue) GetPosition ¶
func (q *BuildQueue) GetPosition(imageName string) *int
func (*BuildQueue) MarkComplete ¶
func (q *BuildQueue) MarkComplete(imageName string)
func (*BuildQueue) PendingCount ¶
func (q *BuildQueue) PendingCount() int
PendingCount returns number of queued builds
func (*BuildQueue) QueueLength ¶
func (q *BuildQueue) QueueLength() int
QueueLength returns the total number of builds (active + pending)
type CreateImageRequest ¶
type CreateImageRequest struct {
Name string
}
CreateImageRequest represents a request to create an image
type ExportFormat ¶
type ExportFormat string
ExportFormat defines supported rootfs export formats
const ( FormatExt4 ExportFormat = "ext4" // Read-only ext4 (app images, default) FormatErofs ExportFormat = "erofs" // Read-only compressed (future: when kernel supports it) FormatCpio ExportFormat = "cpio" // Uncompressed archive (initrd, fast boot) )
type Image ¶
type Image struct {
Name string // Normalized ref (e.g., docker.io/library/alpine:latest)
Digest string // Resolved manifest digest (sha256:...)
Status string
QueuePosition *int
Error *string
SizeBytes *int64
Entrypoint []string
Cmd []string
Env map[string]string
WorkingDir string
CreatedAt time.Time
}
Image represents a container image converted to bootable disk
type Manager ¶
type Manager interface {
ListImages(ctx context.Context) ([]Image, error)
CreateImage(ctx context.Context, req CreateImageRequest) (*Image, error)
// ImportLocalImage imports an image that was pushed to the local OCI cache.
// Unlike CreateImage, it does not resolve from a remote registry.
ImportLocalImage(ctx context.Context, repo, reference, digest string) (*Image, error)
GetImage(ctx context.Context, name string) (*Image, error)
DeleteImage(ctx context.Context, name string) error
RecoverInterruptedBuilds()
// TotalImageBytes returns the total size of all ready images on disk.
// Used by the resource manager for disk capacity tracking.
TotalImageBytes(ctx context.Context) (int64, error)
// TotalOCICacheBytes returns the total size of the OCI layer cache.
// Used by the resource manager for disk capacity tracking.
TotalOCICacheBytes(ctx context.Context) (int64, error)
}
type ManifestInspector ¶
type ManifestInspector interface {
// contains filtered or unexported methods
}
Resolve inspects the manifest to get the digest and returns a ResolvedRef. This requires an ociClient interface for manifest inspection.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics holds the metrics instruments for image operations.
type MirrorRequest ¶ added in v0.0.6
type MirrorRequest struct {
// SourceImage is the full image reference to pull from (e.g., "docker.io/onkernel/nodejs22-base:0.1.1")
SourceImage string
}
MirrorRequest contains the parameters for mirroring a base image
type MirrorResult ¶ added in v0.0.6
type MirrorResult struct {
// SourceImage is the original image reference
SourceImage string `json:"source_image"`
// LocalRef is the local registry reference (e.g., "onkernel/nodejs22-base:0.1.1")
LocalRef string `json:"local_ref"`
// Digest is the image digest
Digest string `json:"digest"`
}
MirrorResult contains the result of a mirror operation
func MirrorBaseImage ¶ added in v0.0.6
func MirrorBaseImage(ctx context.Context, registryURL string, req MirrorRequest, authConfig *authn.AuthConfig) (*MirrorResult, error)
MirrorBaseImage pulls an image from an external registry and pushes it to the local registry with the same normalized name. This enables Dockerfile FROM rewriting to use locally mirrored base images instead of pulling from Docker Hub.
For example, mirroring "docker.io/onkernel/nodejs22-base:0.1.1" will create "onkernel/nodejs22-base:0.1.1" in the local registry.
type NormalizedRef ¶
type NormalizedRef struct {
// contains filtered or unexported fields
}
NormalizedRef is a validated and normalized OCI image reference. It can be either a tagged reference (e.g., "docker.io/library/alpine:latest") or a digest reference (e.g., "docker.io/library/alpine@sha256:abc123...").
func ParseNormalizedRef ¶
func ParseNormalizedRef(s string) (*NormalizedRef, error)
ParseNormalizedRef validates and normalizes a user-provided image reference. Examples:
- "alpine" -> "docker.io/library/alpine:latest"
- "alpine:3.18" -> "docker.io/library/alpine:3.18"
- "alpine@sha256:abc..." -> "docker.io/library/alpine@sha256:abc..."
func (*NormalizedRef) Digest ¶
func (r *NormalizedRef) Digest() string
Digest returns the digest if present (e.g., "sha256:abc123..."). Returns empty string if this is a tagged reference.
func (*NormalizedRef) DigestHex ¶
func (r *NormalizedRef) DigestHex() string
DigestHex returns just the hex portion of the digest (without "sha256:" prefix). Returns empty string if this is a tagged reference.
func (*NormalizedRef) IsDigest ¶
func (r *NormalizedRef) IsDigest() bool
IsDigest returns true if this reference contains a digest (@sha256:...).
func (*NormalizedRef) Repository ¶
func (r *NormalizedRef) Repository() string
Repository returns the repository path without tag or digest. Example: "docker.io/library/alpine"
func (*NormalizedRef) Resolve ¶
func (r *NormalizedRef) Resolve(ctx context.Context, inspector ManifestInspector) (*ResolvedRef, error)
Resolve returns a ResolvedRef by inspecting the manifest to get the authoritative digest.
func (*NormalizedRef) String ¶
func (r *NormalizedRef) String() string
String returns the full normalized reference.
func (*NormalizedRef) Tag ¶
func (r *NormalizedRef) Tag() string
Tag returns the tag if this is a tagged reference (e.g., "latest"). Returns empty string if this is a digest reference.
type OCIClient ¶
type OCIClient struct {
// contains filtered or unexported fields
}
OCIClient is a public wrapper for system manager to use OCI operations
func NewOCIClient ¶
NewOCIClient creates a new OCI client (public for system manager)
func (*OCIClient) InspectManifest ¶
InspectManifest inspects a remote image to get its digest (public for system manager). Always targets Linux platform since hypeman VMs are Linux guests.
func (*OCIClient) InspectManifestForLinux ¶ added in v0.0.6
InspectManifestForLinux is an alias for InspectManifest (all images target Linux)
func (*OCIClient) PullAndUnpack ¶
PullAndUnpack pulls an OCI image and unpacks it to a directory (public for system manager). Always targets Linux platform since hypeman VMs are Linux guests.
type QueuedBuild ¶
type QueuedBuild struct {
ImageName string
Request CreateImageRequest
StartFn func()
}
type ResolvedRef ¶
type ResolvedRef struct {
// contains filtered or unexported fields
}
ResolvedRef is a NormalizedRef that has been resolved to include the actual manifest digest from the registry. The digest is always present.
func NewResolvedRef ¶
func NewResolvedRef(normalized *NormalizedRef, digest string) *ResolvedRef
NewResolvedRef creates a ResolvedRef from a NormalizedRef and digest.
func (*ResolvedRef) Digest ¶
func (r *ResolvedRef) Digest() string
Digest returns the resolved manifest digest (e.g., "sha256:abc123..."). This is always populated after resolution.
func (*ResolvedRef) DigestHex ¶
func (r *ResolvedRef) DigestHex() string
DigestHex returns just the hex portion of the digest (without "sha256:" prefix).
func (*ResolvedRef) Repository ¶
func (r *ResolvedRef) Repository() string
Repository returns the repository path without tag or digest. Example: "docker.io/library/alpine"
func (*ResolvedRef) String ¶
func (r *ResolvedRef) String() string
String returns the full normalized reference (the original user input format).
func (*ResolvedRef) Tag ¶
func (r *ResolvedRef) Tag() string
Tag returns the tag if this was originally a tagged reference (e.g., "latest"). Returns empty string if this was originally a digest reference.