Documentation
¶
Index ¶
- func BindPaths(paths ...string) []string
- func BuildPathEnv(overlays []string) string
- func DeduplicateBindPaths(paths []string) []string
- func DetectGPUFlags() []string
- func FormatOverlayMount(path string, writable bool) string
- func InstalledOverlays() (map[string]string, error)
- func InvalidateInstalledOverlaysCache()
- func ResolveOverlayEnv(overlayPath string) (whatis string, configs, notes map[string]string)
- func ResolveOverlayPaths(inputs []string) ([]string, error)
- type Diagnostic
- type SetupConfig
- type SetupResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindPaths ¶
BindPaths collects all directories suitable for --bind flags. Deduplication and child path filtering is handled by DeduplicateBindPaths().
func BuildPathEnv ¶
BuildPathEnv constructs the PATH environment variable based on overlays. When MPI_DIR is set (exported by condatainer when ntasks > 1), its bin/ is prepended so MPI tools are accessible inside the container.
func DeduplicateBindPaths ¶
DeduplicateBindPaths resolves, deduplicates, and filters child paths from bind directories. It handles formats: "/path", "/path:/container", "/path:/container:ro"
func DetectGPUFlags ¶
func DetectGPUFlags() []string
DetectGPUFlags inspects the host for GPU support and returns the necessary apptainer flags.
func FormatOverlayMount ¶
FormatOverlayMount formats an overlay path with the appropriate :ro or :rw suffix
func InstalledOverlays ¶
InstalledOverlays scans all image search paths and returns a mapping from normalized overlay names to their absolute file path. Searches user → scratch → legacy → system directories. First match wins (user overlays shadow system ones). Result is cached for the lifetime of the process; call InvalidateInstalledOverlaysCache after installing a new overlay.
func InvalidateInstalledOverlaysCache ¶ added in v1.3.0
func InvalidateInstalledOverlaysCache()
InvalidateInstalledOverlaysCache clears the cached overlay map so the next call to InstalledOverlays rescans the image directories.
func ResolveOverlayEnv ¶ added in v1.5.1
ResolveOverlayEnv resolves a single overlay's description (#WHATIS:), env vars, and notes for display. The embedded build script is the source of truth (.sqf); a sidecar <overlay>.env shadows it. $app_root is substituted with the overlay's mount root. A :ro/:rw suffix on the path is ignored.
func ResolveOverlayPaths ¶
ResolveOverlayPaths coerces user input into absolute overlay paths that exist on disk.
Types ¶
type Diagnostic ¶ added in v1.5.0
Diagnostic is a non-fatal setup message returned to presentation layers.
func AutoEnableFakeroot ¶
func AutoEnableFakeroot(lastImg string, writable bool, currentFakeroot bool) (bool, []Diagnostic)
AutoEnableFakeroot checks if fakeroot should be auto-enabled for writable .img overlays Returns the updated fakeroot setting
func CollectOverlayEnv ¶
CollectOverlayEnv resolves environment variables for the given overlay paths and returns environment configs, notes, and non-fatal diagnostics for callers to present or log.
For each overlay the embedded build script (/cnt/<name>/<version>/.cnt-build-script) is the source of truth, keeping the .sqf self-contained; a sidecar <overlay>.env, if present, shadows it for local overrides. $app_root is substituted with the overlay's mount root at load time. When the same variable is set by more than one overlay, the later overlay wins and a diagnostic is recorded.
type SetupConfig ¶
type SetupConfig struct {
Overlays []string // Overlay paths (will be resolved)
WritableImg bool // Whether .img overlays should be writable
EnvSettings []string // User-specified environment variables (KEY=VALUE format)
BindPaths []string // User-specified bind paths
Fakeroot bool // Whether to use fakeroot
ApptainerFlags []string // Additional apptainer flags to pass through
}
SetupConfig holds all configuration needed to set up a container
type SetupResult ¶
type SetupResult struct {
Overlays []string // Resolved and ordered overlay paths
OverlayArgs []string // Overlay paths with :ro/:rw suffixes
EnvList []string // Complete environment variable list
EnvNotes map[string]string // Environment variable notes for display
Diagnostics []Diagnostic // Non-fatal messages for callers to present or log
BindPaths []string // Deduplicated bind paths
Fakeroot bool // Final fakeroot setting (may be auto-enabled)
ApptainerFlags []string // Apptainer flags including GPU flags
LastImg string // Path to .img overlay if present
}
SetupResult contains all the processed configuration ready for container execution
func Setup ¶
func Setup(cfg SetupConfig) (*SetupResult, error)
Setup processes all container configuration and returns a ready-to-use result