Documentation
¶
Index ¶
- Variables
- func DownloadRemoteScript(info ScriptInfo, tmpDir string) (string, error)
- func EnsureBaseImage(ctx context.Context, update bool) error
- func GetAllBuildScripts(includeRemote bool) (map[string]ScriptInfo, error)
- func GetBuildDefaults() scheduler.ResourceSpec
- func GetEnvDictFromBuildScript(scriptPath string) (map[string]EnvEntry, error)
- func GetLocalBuildScripts() (map[string]ScriptInfo, error)
- func GetOverlayArgsFromDependencies(dependencies []string) ([]string, error)
- func GetOverlayEnvConfigsFromDependencies(dependencies []string) ([]string, error)
- func GetPathEnvFromDependencies(dependencies []string) (string, error)
- func GetRemoteBuildScripts() (map[string]ScriptInfo, error)
- func GetRemoteMetadataURL() string
- func SaveEnvFile(overlayPath string, envDict map[string]EnvEntry, relativePath string) error
- func SetBuildDefaults(d scheduler.ResourceSpec)
- type BaseBuildObject
- func (b *BaseBuildObject) BuildSource() string
- func (b *BaseBuildObject) Cleanup(failed bool) error
- func (b *BaseBuildObject) CntDirPath() string
- func (b *BaseBuildObject) CreateTmpOverlay(ctx context.Context, force bool) error
- func (b *BaseBuildObject) Dependencies() []string
- func (b *BaseBuildObject) GetMissingDependencies() ([]string, error)
- func (b *BaseBuildObject) IsInstalled() bool
- func (b *BaseBuildObject) NameVersion() string
- func (b *BaseBuildObject) RequiresScheduler() bool
- func (b *BaseBuildObject) ScriptSpecs() *ScriptSpecs
- func (b *BaseBuildObject) TargetOverlayPath() string
- func (b *BaseBuildObject) TmpOverlayPath() string
- func (b *BaseBuildObject) Update() bool
- type BaseImageBuildObject
- type BuildGraph
- type BuildObject
- func FromExternalSource(ctx context.Context, targetPrefix, source string, isApptainer bool, ...) (BuildObject, error)
- func NewBuildObject(ctx context.Context, nameVersion string, external bool, ...) (BuildObject, error)
- func NewCondaObjectWithSource(nameVersion, buildSource string, imagesDir, tmpDir string, update bool) (BuildObject, error)
- type BuildType
- type CondaBuildObject
- type DefBuildObject
- type EnvEntry
- type RemoteScriptEntry
- type ScriptBuildObject
- type ScriptInfo
- type ScriptSpecs
Constants ¶
This section is empty.
Variables ¶
var ( BuildTypeConda = BuildType{IsConda: true} BuildTypeDef = BuildType{IsDef: true} BuildTypeShell = BuildType{IsShell: true} BuildTypeRef = BuildType{IsShell: true, IsRef: true} )
Predefined build types
var ErrBuildCancelled = errors.New("build cancelled by user")
var ErrTmpOverlayExists = errors.New("temporary overlay already exists")
var PreferRemote bool
PreferRemote controls the precedence of build script resolution. When true, remote scripts take precedence over local scripts. When false (default), local scripts take precedence over remote scripts. Set by CLI commands (--remote flag) or config (prefer_remote: true).
Functions ¶
func DownloadRemoteScript ¶
func DownloadRemoteScript(info ScriptInfo, tmpDir string) (string, error)
DownloadRemoteScript downloads a remote build script to the local tmp directory Returns the local path to the downloaded script
func EnsureBaseImage ¶ added in v1.2.0
EnsureBaseImage is the fast-path entry point for ensuring the base image exists. If the base image is already installed and update=false, returns immediately without constructing any build object or fetching remote metadata.
func GetAllBuildScripts ¶
func GetAllBuildScripts(includeRemote bool) (map[string]ScriptInfo, error)
GetAllBuildScripts returns both local and remote build scripts Local scripts take precedence over remote scripts with the same name
func GetBuildDefaults ¶ added in v1.2.0
func GetBuildDefaults() scheduler.ResourceSpec
GetBuildDefaults returns the current build resource defaults.
func GetEnvDictFromBuildScript ¶
GetEnvDictFromBuildScript parses #ENV:KEY=VALUE and #ENVNOTE:KEY description lines from build script. Returns a map of environment variables with their values and notes.
Example lines in script:
#ENV:STAR_INDEX_DIR=$app_root/star #ENVNOTE:STAR_INDEX_DIR STAR index dir
func GetLocalBuildScripts ¶
func GetLocalBuildScripts() (map[string]ScriptInfo, error)
GetLocalBuildScripts scans all build-scripts directories and returns a map of name -> ScriptInfo. Searches user → scratch → legacy → system directories. First match wins (user scripts shadow system ones).
func GetOverlayArgsFromDependencies ¶
GetOverlayArgsFromDependencies generates overlay mount arguments for Apptainer from dependencies. Each dependency is mounted as read-only.
func GetOverlayEnvConfigsFromDependencies ¶
GetOverlayEnvConfigsFromDependencies reads .env files from dependencies and returns environment settings. Returns a list of ["--env", "KEY=VALUE", ...] arguments.
func GetPathEnvFromDependencies ¶
GetPathEnvFromDependencies generates the PATH environment variable from dependencies. It prepends /cnt/<dep>/bin paths for each dependency overlay.
func GetRemoteBuildScripts ¶
func GetRemoteBuildScripts() (map[string]ScriptInfo, error)
GetRemoteBuildScripts fetches the build scripts metadata from GitHub Returns a map of name -> ScriptInfo
func GetRemoteMetadataURL ¶ added in v1.1.1
func GetRemoteMetadataURL() string
GetRemoteMetadataURL returns the URL for the remote build scripts metadata using the configured scripts_link
func SaveEnvFile ¶
SaveEnvFile saves environment variables to a .env file next to the overlay. The $app_root placeholder is replaced with the actual overlay path.
func SetBuildDefaults ¶ added in v1.2.0
func SetBuildDefaults(d scheduler.ResourceSpec)
SetBuildDefaults sets the resource defaults used for build job submissions.
Types ¶
type BaseBuildObject ¶
type BaseBuildObject struct {
// contains filtered or unexported fields
}
BaseBuildObject provides common functionality for all build types
func (*BaseBuildObject) BuildSource ¶
func (b *BaseBuildObject) BuildSource() string
func (*BaseBuildObject) Cleanup ¶
func (b *BaseBuildObject) Cleanup(failed bool) error
func (*BaseBuildObject) CntDirPath ¶
func (b *BaseBuildObject) CntDirPath() string
func (*BaseBuildObject) CreateTmpOverlay ¶
func (b *BaseBuildObject) CreateTmpOverlay(ctx context.Context, force bool) error
func (*BaseBuildObject) Dependencies ¶
func (b *BaseBuildObject) Dependencies() []string
func (*BaseBuildObject) GetMissingDependencies ¶
func (b *BaseBuildObject) GetMissingDependencies() ([]string, error)
func (*BaseBuildObject) IsInstalled ¶
func (b *BaseBuildObject) IsInstalled() bool
func (*BaseBuildObject) NameVersion ¶
func (b *BaseBuildObject) NameVersion() string
func (*BaseBuildObject) RequiresScheduler ¶
func (b *BaseBuildObject) RequiresScheduler() bool
func (*BaseBuildObject) ScriptSpecs ¶
func (b *BaseBuildObject) ScriptSpecs() *ScriptSpecs
func (*BaseBuildObject) TargetOverlayPath ¶
func (b *BaseBuildObject) TargetOverlayPath() string
func (*BaseBuildObject) TmpOverlayPath ¶
func (b *BaseBuildObject) TmpOverlayPath() string
func (*BaseBuildObject) Update ¶ added in v1.2.0
func (b *BaseBuildObject) Update() bool
type BaseImageBuildObject ¶ added in v1.2.0
type BaseImageBuildObject struct {
*DefBuildObject
}
BaseImageBuildObject wraps DefBuildObject but overrides IsInstalled() to search all configured image paths (not just the writable directory).
func NewBaseImageBuildObject ¶ added in v1.2.0
func NewBaseImageBuildObject(update bool) (*BaseImageBuildObject, error)
NewBaseImageBuildObject creates a BuildObject for the base image using the same path resolution as regular build objects. base_image.def is searched in the build-scripts directories (same structure as any other build script) and downloaded from GitHub if not found locally. When the def comes from GitHub, BaseImageBuildObject also tries to download a prebuilt .sif before falling back to a local build.
When update=false the build is skipped if the image already exists anywhere in the configured search paths. When update=true the image is always rebuilt (written to .new then atomically renamed).
func (*BaseImageBuildObject) Build ¶ added in v1.2.0
func (b *BaseImageBuildObject) Build(ctx context.Context, buildDeps bool) error
Build overrides DefBuildObject.Build for base images. Unlike regular def builds, the SIF produced by apptainer is kept directly as the final image — no SquashFS extraction step is performed.
func (*BaseImageBuildObject) IsInstalled ¶ added in v1.2.0
func (b *BaseImageBuildObject) IsInstalled() bool
IsInstalled checks all image search paths for the base image.
type BuildGraph ¶
type BuildGraph struct {
// contains filtered or unexported fields
}
BuildGraph manages dependency resolution and build ordering It expands BuildObject items to include all transitive dependencies, detects cycles, produces a topologically-sorted order (dependencies before dependents), and separates items into two ordered lists:
- localBuilds: BuildObjects without scheduler requirements (build locally)
- schedulerBuilds: BuildObjects that require scheduler submission
func NewBuildGraph ¶
func NewBuildGraph(ctx context.Context, buildObjects []BuildObject, imagesDir, tmpDir string, submitJobs bool, update bool) (*BuildGraph, error)
NewBuildGraph creates a BuildGraph from a list of BuildObjects All overlays are stored in imagesDir regardless of type
func (*BuildGraph) GetJobIDs ¶
func (bg *BuildGraph) GetJobIDs() map[string]string
GetJobIDs returns the map of job IDs for scheduler builds
type BuildObject ¶
type BuildObject interface {
// Core properties
NameVersion() string
BuildSource() string
Dependencies() []string
IsInstalled() bool
// Type information
Type() BuildType
// Path management
TmpOverlayPath() string
TargetOverlayPath() string
CntDirPath() string
// Scheduler metadata
ScriptSpecs() *ScriptSpecs
RequiresScheduler() bool
// Build operations
Build(ctx context.Context, buildDeps bool) error
GetMissingDependencies() ([]string, error)
CreateTmpOverlay(ctx context.Context, force bool) error
Cleanup(failed bool) error
// Update mode
Update() bool
// String representation
String() string
}
BuildObject represents a build target with its metadata and dependencies
func FromExternalSource ¶
func FromExternalSource(ctx context.Context, targetPrefix, source string, isApptainer bool, imagesDir, tmpDir string) (BuildObject, error)
FromExternalSource creates a BuildObject from an external build script or def file All overlays are stored in imagesDir regardless of type
func NewBuildObject ¶
func NewBuildObject(ctx context.Context, nameVersion string, external bool, imagesDir, tmpDir string, update bool) (BuildObject, error)
NewBuildObject creates a BuildObject from a name/version string Format: "name/version" for conda/shell, "name" for def, "prefix/name/version" for ref All overlays are stored in imagesDir regardless of type
func NewCondaObjectWithSource ¶
func NewCondaObjectWithSource(nameVersion, buildSource string, imagesDir, tmpDir string, update bool) (BuildObject, error)
NewCondaObjectWithSource creates a CondaBuildObject with custom buildSource This is used for the -n flag to create a single sqf with multiple packages or YAML buildSource can be:
- Path to YAML file (e.g., "/path/to/environment.yml")
- Comma-separated package list (e.g., "nvim,nodejs,samtools/1.16")
type CondaBuildObject ¶
type CondaBuildObject struct {
*BaseBuildObject
// contains filtered or unexported fields
}
CondaBuildObject implements BuildObject for conda packages Supports three modes: 1. Single package (name/version): packageName and packageVersion are set 2. Multiple packages (-n flag): buildSource contains comma-separated package specs 3. YAML file (-p flag): buildSource contains path to .yml/.yaml file
func (*CondaBuildObject) Build ¶
func (c *CondaBuildObject) Build(ctx context.Context, buildDeps bool) error
Build implements the conda package build workflow Workflow:
- Check if overlay already exists (skip if yes)
- Create temporary ext3 overlay
- Run micromamba create inside container with overlay
- Set permissions
- Pack to SquashFS
- Cleanup
func (*CondaBuildObject) String ¶
func (c *CondaBuildObject) String() string
String returns a string representation
func (*CondaBuildObject) Type ¶
func (c *CondaBuildObject) Type() BuildType
Type returns the build type
type DefBuildObject ¶
type DefBuildObject struct {
*BaseBuildObject
}
DefBuildObject implements BuildObject for Apptainer definition files
func (*DefBuildObject) Build ¶
func (d *DefBuildObject) Build(ctx context.Context, buildDeps bool) error
Build implements the Apptainer .def build workflow Workflow:
- Check if overlay already exists (skip if yes)
- Try downloading prebuilt overlay if available
- Build SIF from .def file using apptainer build --fakeroot
- Extract SquashFS partition from SIF
- Set permissions
- Cleanup
func (*DefBuildObject) String ¶
func (d *DefBuildObject) String() string
String returns a string representation
type RemoteScriptEntry ¶
type RemoteScriptEntry struct {
RelativePath string `json:"relative_path"`
Deps []string `json:"deps"`
Whatis string `json:"whatis"`
}
RemoteScriptEntry represents a single script entry in the metadata
type ScriptBuildObject ¶
type ScriptBuildObject struct {
*BaseBuildObject
// contains filtered or unexported fields
}
ScriptBuildObject implements BuildObject for shell scripts
func (*ScriptBuildObject) Build ¶
func (s *ScriptBuildObject) Build(ctx context.Context, buildDeps bool) error
Build implements the shell script build workflow Workflow:
- Check if overlay already exists (skip if yes)
- Create temporary ext3 overlay
- Check and build missing dependencies if buildDeps=true
- Run shell script inside container with overlays
- For ref overlays: verify files exist, create SquashFS from cnt_dir
- For app overlays: set permissions, create SquashFS from /cnt
- Extract and save ENV variables if present
- Set permissions and cleanup
func (*ScriptBuildObject) String ¶
func (s *ScriptBuildObject) String() string
String returns a string representation
func (*ScriptBuildObject) Type ¶
func (s *ScriptBuildObject) Type() BuildType
Type returns the build type
type ScriptInfo ¶
type ScriptInfo struct {
Name string // name/version format (e.g., "samtools/1.21")
Path string // full path to build script (local) or relative path (remote)
IsContainer bool // true if .def file
IsRemote bool // true if from remote repository
}
ScriptInfo holds information about a build script
func FindBuildScript ¶
func FindBuildScript(nameVersion string) (ScriptInfo, bool)
FindBuildScript looks for a build script by name/version. By default, local scripts take precedence over remote. When PreferRemote is true, remote scripts take precedence over local. Returns the ScriptInfo and a boolean indicating if it was found.
type ScriptSpecs ¶
type ScriptSpecs = scheduler.ScriptSpecs
ScriptSpecs mirrors the scheduler module's job spec metadata.