Documentation
¶
Index ¶
- func ExportToDir(img *Image, dstDir string) error
- func IsLocalTar(imageRef string) bool
- func ParseImageRef(imageRef string) (registry string, image string, tag string, err error)
- func ValidateImageName(imageRef string, checkRegistry bool) error
- func ValidateTar(tarPath string) error
- type ArchitectureMismatchError
- type Client
- func (c *Client) CacheDir() string
- func (c *Client) LoadFromTar(tarPath string, arch hv.CpuArchitecture) (*Image, error)
- func (c *Client) Pull(imageRef string) (*Image, error)
- func (c *Client) PullForArch(imageRef string, arch hv.CpuArchitecture) (*Image, error)
- func (c *Client) SetBlobContext(index, count int)
- func (c *Client) SetProgressCallback(callback ProgressCallback)
- type ContainerFS
- func (cfs *ContainerFS) Close() error
- func (cfs *ContainerFS) Lookup(name string) (vfs.AbstractEntry, error)
- func (cfs *ContainerFS) ModTime() time.Time
- func (cfs *ContainerFS) ReadDir() ([]vfs.AbstractDirEntry, error)
- func (cfs *ContainerFS) ResolvePath(p string) (string, error)
- func (cfs *ContainerFS) Stat() fs.FileMode
- type DownloadProgress
- type Image
- type ImageLayer
- type LayeredContainerFS
- func (lcfs *LayeredContainerFS) Base() *ContainerFS
- func (lcfs *LayeredContainerFS) Close() error
- func (lcfs *LayeredContainerFS) Lookup(name string) (vfs.AbstractEntry, error)
- func (lcfs *LayeredContainerFS) ModTime() time.Time
- func (lcfs *LayeredContainerFS) ReadDir() ([]vfs.AbstractDirEntry, error)
- func (lcfs *LayeredContainerFS) Stat() fs.FileMode
- type ProgressCallback
- type RuntimeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportToDir ¶
ExportToDir copies the prebaked runtime artifacts for img into dstDir. The destination will contain config.json plus all referenced *.idx/*.contents.
func IsLocalTar ¶
IsLocalTar checks if the image reference is a local tar file.
func ParseImageRef ¶
ParseImageRef parses an OCI image reference into registry, image, and tag.
func ValidateImageName ¶ added in v0.0.2
ValidateImageName validates an OCI image name format and optionally checks if it exists in the registry. If checkRegistry is true, it will make a HEAD request to verify the image exists.
func ValidateTar ¶ added in v0.0.2
ValidateTar checks if a file is a valid Docker/OCI tar archive. It opens the tar and verifies it contains a valid manifest.json.
Types ¶
type ArchitectureMismatchError ¶ added in v0.0.2
ArchitectureMismatchError is returned when an image's architecture doesn't match the expected architecture.
func (*ArchitectureMismatchError) Error ¶ added in v0.0.2
func (e *ArchitectureMismatchError) Error() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an OCI registry client that handles image pulling and caching.
func (*Client) LoadFromTar ¶
LoadFromTar loads a Docker image from a tar archive created by `docker save`.
func (*Client) PullForArch ¶
PullForArch downloads an OCI image for a specific architecture.
func (*Client) SetBlobContext ¶ added in v0.0.2
SetBlobContext sets the current blob index and total count for progress reporting. This should be called before each blob download to track overall progress.
func (*Client) SetProgressCallback ¶
func (c *Client) SetProgressCallback(callback ProgressCallback)
SetProgressCallback sets a callback function that will be called during downloads. The callback receives progress updates with current/total bytes and filename. Set to nil to disable progress reporting.
type ContainerFS ¶
type ContainerFS struct {
// contains filtered or unexported fields
}
ContainerFS implements vfs.AbstractDir to provide a layered filesystem view of an OCI container image.
func NewContainerFS ¶
func NewContainerFS(img *Image) (*ContainerFS, error)
NewContainerFS creates a new container filesystem from an OCI image.
func (*ContainerFS) Close ¶
func (cfs *ContainerFS) Close() error
Close releases resources held by the container filesystem.
func (*ContainerFS) Lookup ¶
func (cfs *ContainerFS) Lookup(name string) (vfs.AbstractEntry, error)
Lookup implements vfs.AbstractDir.
func (*ContainerFS) ModTime ¶
func (cfs *ContainerFS) ModTime() time.Time
ModTime implements vfs.AbstractDir.
func (*ContainerFS) ReadDir ¶
func (cfs *ContainerFS) ReadDir() ([]vfs.AbstractDirEntry, error)
ReadDir implements vfs.AbstractDir.
func (*ContainerFS) ResolvePath ¶
func (cfs *ContainerFS) ResolvePath(p string) (string, error)
ResolvePath resolves a path within the container filesystem, following symlinks (including in intermediate components). The returned path is absolute (starts with "/").
This is useful for exec'ing symlink entrypoints as their real targets so the dynamic loader sees the correct executable location (e.g. for $ORIGIN-based RUNPATH).
func (*ContainerFS) Stat ¶
func (cfs *ContainerFS) Stat() fs.FileMode
Stat implements vfs.AbstractDir.
type DownloadProgress ¶
type DownloadProgress struct {
Current int64 // Bytes downloaded so far
Total int64 // Total bytes to download (-1 if unknown)
Filename string // Name/path being downloaded
// Blob count tracking
BlobIndex int // Index of current blob (0-based)
BlobCount int // Total number of blobs to download
// Speed and ETA tracking
BytesPerSecond float64 // Current download speed in bytes per second
ETA time.Duration // Estimated time remaining (-1 if unknown)
}
DownloadProgress represents the current state of a download.
type Image ¶
type Image struct {
Config RuntimeConfig
Layers []ImageLayer
Dir string // directory containing the image files
}
Image represents a pulled OCI image ready for use.
func LoadFromDir ¶
LoadFromDir loads an image from a prebaked directory containing config.json and layer *.idx/*.contents files.
func LoadFromDirForArch ¶ added in v0.0.2
func LoadFromDirForArch(dir string, expectedArch hv.CpuArchitecture) (*Image, error)
LoadFromDirForArch loads an image from a prebaked directory and validates that the image architecture matches the expected architecture.
type ImageLayer ¶
type ImageLayer struct {
Hash string // sha256:... digest
IndexPath string // path to .idx file
ContentsPath string // path to .contents file
}
ImageLayer represents a single layer in an OCI image.
type LayeredContainerFS ¶ added in v0.0.2
type LayeredContainerFS struct {
// contains filtered or unexported fields
}
LayeredContainerFS wraps a ContainerFS and adds additional layers on top. It implements vfs.AbstractDir to provide a unified view of all layers.
func NewLayeredContainerFS ¶ added in v0.0.2
func NewLayeredContainerFS(base *ContainerFS, layers []ImageLayer) (*LayeredContainerFS, error)
NewLayeredContainerFS creates a new layered container filesystem.
func (*LayeredContainerFS) Base ¶ added in v0.0.2
func (lcfs *LayeredContainerFS) Base() *ContainerFS
Base returns the underlying ContainerFS.
func (*LayeredContainerFS) Close ¶ added in v0.0.2
func (lcfs *LayeredContainerFS) Close() error
Close releases resources held by the layered container filesystem.
func (*LayeredContainerFS) Lookup ¶ added in v0.0.2
func (lcfs *LayeredContainerFS) Lookup(name string) (vfs.AbstractEntry, error)
Lookup implements vfs.AbstractDir.
func (*LayeredContainerFS) ModTime ¶ added in v0.0.2
func (lcfs *LayeredContainerFS) ModTime() time.Time
ModTime implements vfs.AbstractDir.
func (*LayeredContainerFS) ReadDir ¶ added in v0.0.2
func (lcfs *LayeredContainerFS) ReadDir() ([]vfs.AbstractDirEntry, error)
ReadDir implements vfs.AbstractDir.
func (*LayeredContainerFS) Stat ¶ added in v0.0.2
func (lcfs *LayeredContainerFS) Stat() fs.FileMode
Stat implements vfs.AbstractDir.
type ProgressCallback ¶
type ProgressCallback func(progress DownloadProgress)
ProgressCallback is called periodically during downloads.
type RuntimeConfig ¶
type RuntimeConfig struct {
Layers []string `json:"layers"`
Env []string `json:"env,omitempty"`
Entrypoint []string `json:"entrypoint,omitempty"`
Cmd []string `json:"cmd,omitempty"`
WorkingDir string `json:"workingDir,omitempty"`
User string `json:"user,omitempty"`
UID *int `json:"uid,omitempty"`
GID *int `json:"gid,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Architecture string `json:"architecture,omitempty"`
}
RuntimeConfig holds the runtime configuration extracted from an OCI image.