Documentation
¶
Index ¶
- Constants
- func AutoDetectCompression(supportsZstd bool)
- func DetectApptainerBin() string
- func DetectSchedulerBin() string
- func DirExists(path string) bool
- func FindBaseImage() string
- func FindBaseImageDef() string
- func FindBuildScriptFile(name string) (string, error)
- func FindHelperScript(name string) (string, error)
- func FindImage(name string) (string, error)
- func ForceDetectAndSave() (bool, error)
- func ForceDetectAndSaveTo(configPath string) (bool, error)
- func GetActiveOrUserConfigPath() (string, error)
- func GetBaseImage() string
- func GetBaseImageDefWritePath() (string, error)
- func GetBaseImageWritePath() (string, error)
- func GetBuildScriptSearchPaths() []string
- func GetConfigPathByLocation(location string) (string, error)
- func GetDefaultConfigPath() (string, error)
- func GetExistingBuildScriptPaths() []string
- func GetExistingHelperScriptPaths() []string
- func GetExistingImagePaths() []string
- func GetExtraBaseDirs() []string
- func GetHelperScriptSearchPaths() []string
- func GetImageSearchPaths() []string
- func GetPortableBinDir() string
- func GetPortableConfigPath() string
- func GetPortableDataDir() string
- func GetSchedulerTypeFromBin(binPath string) string
- func GetScratchDataDir() string
- func GetSystemConfigPath() string
- func GetSystemDataDir() string
- func GetUserConfigPath() (string, error)
- func GetUserDataDir() string
- func GetWritableBuildScriptsDir() (string, error)
- func GetWritableHelperScriptsDir() (string, error)
- func GetWritableImagesDir() (string, error)
- func GetWritableTmpDir() string
- func InitDataPaths()
- func InitViper() error
- func IsInsideContainer() bool
- func IsPortable() bool
- func IsPortableInstallation() bool
- func LoadDefaults(executablePath string)
- func LoadFromViper()
- func SaveConfig() error
- func SaveConfigTo(configPath string) error
- func SetCompressArgsInConfig(compressArgs string) error
- func SetCompressArgsInConfigTo(compressArgs, configPath string) error
- func ValidateBinary(binPath string) bool
- type BuildConfig
- type Config
- type ConfigSearchPath
- type DataPaths
- type ImageInfo
- type ScriptFileInfo
Constants ¶
const BaseImageDefName = "base_image.def"
BaseImageDefName is the filename for the base image definition file.
const BaseImageName = "base_image.sif"
BaseImageName is the filename for the base container image.
const ConfigFilename = "config"
ConfigFilename is the name of the config file
const ConfigType = "yaml"
ConfigType is the type of config file (yaml, json, toml)
const GITHUB_REPO = GitHubRepo // Exported constant for compatibility
const GitHubRepo = "Justype/condatainer"
const PrebuiltBaseURL = "https://github.com/Justype/cnt-prebuilt/releases/download/prebuilt"
PrebuiltBaseURL is the base URL for downloading prebuilt images and overlays
const VERSION = "1.1.0"
Variables ¶
This section is empty.
Functions ¶
func AutoDetectCompression ¶
func AutoDetectCompression(supportsZstd bool)
AutoDetectCompression sets compression to zstd if supported and user hasn't explicitly set it. This should be called after apptainer version is known. supportsZstd: whether the current apptainer version supports zstd (>= 1.4)
func DetectApptainerBin ¶
func DetectApptainerBin() string
DetectApptainerBin attempts to find apptainer binary Returns the full absolute path if found, empty string otherwise
func DetectSchedulerBin ¶
func DetectSchedulerBin() string
DetectSchedulerBin attempts to find scheduler binary Returns the binary path if found, empty string otherwise
func FindBaseImage ¶
func FindBaseImage() string
FindBaseImage searches all image paths for the base image. Returns the full path if found, empty string otherwise.
func FindBaseImageDef ¶
func FindBaseImageDef() string
FindBaseImageDef searches all build-scripts paths for the base image definition file. Returns the full path if found, empty string otherwise.
func FindBuildScriptFile ¶
FindBuildScriptFile searches all build script paths for a script by name. Returns the full path to the script if found.
func FindHelperScript ¶
FindHelperScript searches all helper script paths for a script by name. Returns the full path to the script if found.
func FindImage ¶
FindImage searches all image paths for an image by name. Returns the full path to the image if found.
func ForceDetectAndSave ¶
ForceDetectAndSave always re-detects binaries from current environment and saves This is useful for config init to capture the exact paths from current PATH Returns true if config was updated
func ForceDetectAndSaveTo ¶
ForceDetectAndSaveTo always re-detects binaries and saves to the specified path Returns true if config was updated
func GetActiveOrUserConfigPath ¶
GetActiveOrUserConfigPath returns the currently active config file path, or the user config path if no config is currently active. This ensures that 'config set' updates the in-use config rather than always creating/updating the user config.
func GetBaseImage ¶
func GetBaseImage() string
GetBaseImage returns the path to base_image.sif, searching all image directories. Searches all directories and returns the first found, or falls back to first writable path.
func GetBaseImageDefWritePath ¶
GetBaseImageDefWritePath returns the path where a new base image def should be written. This is the first writable build-scripts directory + base_image.def
func GetBaseImageWritePath ¶
GetBaseImageWritePath returns the path where a new base image should be written. This is the first writable images directory + base_image.sif
func GetBuildScriptSearchPaths ¶
func GetBuildScriptSearchPaths() []string
GetBuildScriptSearchPaths returns all paths to search for build scripts.
func GetConfigPathByLocation ¶
GetConfigPathByLocation returns the config path for the specified location type. Supported locations: "user"/"u", "portable"/"p", "system"/"s"
func GetDefaultConfigPath ¶
GetDefaultConfigPath returns the recommended config path based on installation type. - If in a portable installation (bin/ folder), returns the portable path - Otherwise, returns the user config path (~/.config/condatainer/config.yaml)
func GetExistingBuildScriptPaths ¶
func GetExistingBuildScriptPaths() []string
GetExistingBuildScriptPaths returns only the build script search paths that actually exist.
func GetExistingHelperScriptPaths ¶
func GetExistingHelperScriptPaths() []string
GetExistingHelperScriptPaths returns only the helper script search paths that actually exist.
func GetExistingImagePaths ¶
func GetExistingImagePaths() []string
GetExistingImagePaths returns only the image search paths that actually exist.
func GetExtraBaseDirs ¶
func GetExtraBaseDirs() []string
GetExtraBaseDirs returns extra base directories from config or environment. Environment variable CONDATAINER_EXTRA_BASE_DIRS uses colon-separated paths (Unix convention). Config file uses YAML array format.
func GetHelperScriptSearchPaths ¶
func GetHelperScriptSearchPaths() []string
GetHelperScriptSearchPaths returns all paths to search for helper scripts.
func GetImageSearchPaths ¶
func GetImageSearchPaths() []string
GetImageSearchPaths returns all paths to search for images.
func GetPortableBinDir ¶
func GetPortableBinDir() string
GetPortableBinDir returns the bin directory of a portable installation, or empty string if not portable. This is typically used to add the installation's bin directory to PATH for nested usage.
func GetPortableConfigPath ¶
func GetPortableConfigPath() string
GetPortableConfigPath returns the portable config path if the executable is in a dedicated installation (bin/ folder that's not a common user/system bin). Returns empty string if not in a portable installation.
func GetPortableDataDir ¶
func GetPortableDataDir() string
GetPortableDataDir returns the portable data directory for group/shared use. Only detects truly portable installations - directories next to the executable that are NOT in standard user locations (~/.config, ~/.local, etc.). This is useful for shared group directories or portable installations.
Detection logic:
- If executable is in <dir>/bin/, check if <dir> has images/ subdirectory
- Otherwise check for <exeDir>/condatainer/ directory
func GetSchedulerTypeFromBin ¶
GetSchedulerTypeFromBin derives the scheduler type from the binary path/name. The type is always inferred from the binary - it cannot be set independently.
func GetScratchDataDir ¶
func GetScratchDataDir() string
GetScratchDataDir returns the scratch data directory for HPC systems. Returns $SCRATCH/condatainer if SCRATCH is set.
func GetSystemConfigPath ¶
func GetSystemConfigPath() string
GetSystemConfigPath returns the system-wide config path
func GetSystemDataDir ¶
func GetSystemDataDir() string
GetSystemDataDir returns the system-wide data directory. Checks XDG_DATA_DIRS first, then standard paths.
func GetUserConfigPath ¶
GetUserConfigPath returns the path to the user config file
func GetUserDataDir ¶
func GetUserDataDir() string
GetUserDataDir returns the user's data directory following XDG spec. Returns $XDG_DATA_HOME/condatainer or ~/.local/share/condatainer
func GetWritableBuildScriptsDir ¶
GetWritableBuildScriptsDir returns the first writable build scripts directory.
func GetWritableHelperScriptsDir ¶
GetWritableHelperScriptsDir returns the first writable helper scripts directory.
func GetWritableImagesDir ¶
GetWritableImagesDir returns the first writable images directory. Creates the directory if it doesn't exist.
func GetWritableTmpDir ¶
func GetWritableTmpDir() string
GetWritableTmpDir returns the first writable tmp directory
func InitDataPaths ¶
func InitDataPaths()
InitDataPaths initializes GlobalDataPaths based on environment and config. This should be called after LoadDefaults and LoadFromViper.
func InitViper ¶
func InitViper() error
InitViper initializes Viper with proper search paths and defaults Priority (highest to lowest): 1. Command-line flags (handled by cobra) 2. Environment variables (CONDATAINER_*) 3. User config file (~/.config/condatainer/config.yaml) 4. Portable config (parent of bin/ folder where executable lives) 5. System config file (/etc/condatainer/config.yaml) 6. Defaults
Rationale: User config takes priority over portable/shared config, allowing users to override shared defaults (e.g., API keys, queues) without affecting other users of the shared installation.
func IsInsideContainer ¶
func IsInsideContainer() bool
IsInsideContainer checks if we're currently running inside a container
func IsPortable ¶
func IsPortable() bool
IsPortable returns true if the current installation is portable (not in standard user locations). This is useful for determining if nested PATH updates should include the installation's bin directory.
func IsPortableInstallation ¶
func IsPortableInstallation() bool
IsPortableInstallation returns true if the executable is in a portable installation
func LoadDefaults ¶
func LoadDefaults(executablePath string)
func SaveConfig ¶
func SaveConfig() error
SaveConfig saves current Viper config to the active config file, or to user config file if no config is currently active
func SaveConfigTo ¶
SaveConfigTo saves current Viper config to the specified path
func SetCompressArgsInConfig ¶
SetCompressArgsInConfig saves the compress_args to config file This is called during config init to persist the auto-detected compression
func SetCompressArgsInConfigTo ¶
SetCompressArgsInConfigTo saves the compress_args to the specified config file
func ValidateBinary ¶
ValidateBinary checks if a binary exists and is executable
Types ¶
type BuildConfig ¶
type BuildConfig struct {
DefaultCPUs int // Default CPUs for builds (if not specified in script)
DefaultMemMB int64 // Default memory for builds in MB
DefaultTime time.Duration // Default time limit
TmpSizeMB int // Size of temporary overlay in MB
CompressArgs string // mksquashfs compression arguments
OverlayType string // Overlay filesystem type: "ext3" or "squashfs"
}
BuildConfig holds default settings for build operations
type Config ¶
type Config struct {
// Runtime settings
Debug bool
SubmitJob bool
Version string
// Directory paths
ProgramDir string
LogsDir string
// Binary paths
ApptainerBin string
SchedulerBin string // Optional: path to sbatch/scheduler binary (auto-detected if empty)
// Build configuration
Build BuildConfig
}
Config holds global application settings
var Global Config
Global holds the singleton configuration instance
type ConfigSearchPath ¶
type ConfigSearchPath struct {
Path string // Full path to config file
Type string // Type: "portable", "user", "system", "cwd"
Exists bool // Whether the file exists
InUse bool // Whether this is the active config file
}
ConfigSearchPath represents a config file location with metadata
func GetConfigSearchPaths ¶
func GetConfigSearchPaths() []ConfigSearchPath
GetConfigSearchPaths returns all config search paths in priority order. This matches the order used by InitViper.
type DataPaths ¶
type DataPaths struct {
ImagesDirs []string // Search paths for images
BuildScriptsDirs []string // Search paths for build scripts
HelperScriptsDirs []string // Search paths for helper scripts
}
DataPaths holds the search paths for data directories. Search order: extra → portable → scratch → user (first match wins for lookups). Write operations go to the first writable path in the same order.
var GlobalDataPaths DataPaths
GlobalDataPaths holds the computed data paths
type ImageInfo ¶
type ImageInfo struct {
Name string // Filename (e.g., "python.sqf")
Path string // Full absolute path
Source string // Source directory type: "extra", "portable", "scratch", "user", or "legacy"
}
ImageInfo holds information about an image found during enumeration.
func ListAllImages ¶
ListAllImages returns all images from all search paths. Images in higher-priority directories shadow those in lower-priority ones.
type ScriptFileInfo ¶
type ScriptFileInfo struct {
Name string // Filename
Path string // Full absolute path
Source string // Source directory type
}
ScriptFileInfo holds information about a script found during enumeration.
func ListAllBuildScripts ¶
func ListAllBuildScripts() ([]ScriptFileInfo, error)
ListAllBuildScripts returns all build scripts from all search paths.
func ListAllHelperScripts ¶
func ListAllHelperScripts() ([]ScriptFileInfo, error)
ListAllHelperScripts returns all helper scripts from all search paths.