config

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

config

Multi-level configuration management and data directory search following XDG Base Directory specification.

Architecture

config.go       Global config singleton, defaults, structure
datapaths.go    Data directory search paths and resolution
persist.go      Configuration file loading (Viper)

Configuration Hierarchy

Two independent mechanisms with different semantics:

1. Environment variables (CNT_*) — admin-level control (e.g. set in a module file). Always replaces the config file value for that key entirely.

2. Config files — layered user/group/system config. All existing files are loaded:

  • Scalar keys (apptainer_bin, default_distro, etc.): highest-priority file that sets the key wins.
  • Array keys (extra_*_dirs, extra_scripts_links): merged across all layers (user ++ extra-root ++ root ++ system), deduplicated, user entries first.
  • channels: overwrite — highest-priority config file that sets it wins (not merged).

Priority order (highest to lowest):

  1. Command-line flags
  2. Environment variables (CNT_*) — replaces, not merged
  3. User config (~/.config/condatainer/config.yaml)
  4. Extra-root config ($CNT_EXTRA_ROOT/config.yaml, group/lab layer)
  5. App-root config ($CNT_ROOT/config.yaml or <install>/config.yaml)
  6. System config (/etc/condatainer/config.yaml)
  7. Hardcoded defaults

Global Config

config.Global  // Singleton instance

Fields:

  • Debug, SubmitJob, Version
  • ProgramDir, LogsDir
  • ApptainerBin, SchedulerBin
  • DefaultDistro - Base OS slug (e.g. "ubuntu24")
  • Branch, PreferRemote (remote script fetching)
  • ParseModuleLoad - Treat module load lines as #DEP dependencies
  • Notification - Notification method when a helper job starts (default: "" = none). Values: "bell" (terminal bell), "email" (scheduler email directive), ≥5-char string (ntfy.sh topic, fires from compute node), "" or "none" (silent).
  • ProxyPerJob - Auto-start a per-job SOCKS5 proxy inside submitted jobs when no active proxy is found (proxy_perjob config key, default: false)
  • Scheduler scheduler.ResourceSpec - Default scheduler specs (Nodes, TasksPerNode, CpusPerTask, MemPerNodeMB, Time)
  • Build BuildConfig - Build settings (Defaults scheduler.ResourceSpec, TmpSizeMB, CompressArgs, OverlayType)

Search order for images:

  1. extra_image_dirs — explicit image directories (direct paths, support :ro/:rw)
  2. CNT_EXTRA_ROOT → <extra-root>/images/ (group/lab layer)
  3. Root dir → $CNT_ROOT/images/ or <install>/images/
  4. Scratch dir → $SCRATCH/condatainer/images/
  5. User dir → $XDG_DATA_HOME/condatainer/images/ or ~/.local/share/condatainer/images/

Search order for scripts: Build scripts:

  1. extra_build_dirs — explicit build-scripts directories (direct paths)
  2. CNT_EXTRA_ROOT, Root dir, Scratch dir, User dir (same pattern)

Helper scripts:

  1. extra_helper_dirs — explicit helper-scripts directories (direct paths)
  2. CNT_EXTRA_ROOT, Root dir, Scratch dir, User dir (same pattern)

Write operations:

  • Images / helpers: first writable directory in search order. :ro entries and extra_build_dirs are always skipped. Personal dirs (scratch, user) are always created on first use. Shared dirs (extra-root, root): subdirs (images/, build-scripts/, etc.) are auto-created if the parent directory already exists — the parent itself is never auto-created.
  • Cache: always written to a personal directory (scratch → user cache) to avoid cross-user pollution. Shared dirs are never written to.

:ro / :rw markers (image and helper dirs, config file only):

  • :ro — search-only; condatainer never writes here even if filesystem allows it
  • :rw — explicit writable annotation (same as no marker; for documentation clarity)
  • Only applies to extra_image_dirs and extra_helper_dirs; extra_build_dirs entries are plain paths

Usage

config.LoadDefaults("/path/to/condatainer")  // load defaults
config.InitViper()                           // load config files

config.GetBaseImage()                        // base image path (search all)
config.GetWritableImagesDir()                // writable images directory
config.FindImage("cellranger--9.0.1.sqf")   // search all image paths
config.FindHelperScript("jupyter")           // search helper script paths

config.GlobalDataPaths.ImagesDirs           // ordered image search paths
config.GlobalDataPaths.BuildScriptsDirs     // ordered script search paths
config.GetUserStateDir()                    // instance state directory
config.GetWritableCacheDir()                // personal writable cache directory (scratch → user)
config.GetCacheSearchPaths()                // personal cache search paths

Environment Variables

All multi-value env vars use | as separator. CNT_EXTRA_BUILD_DIRS also accepts :.

Variable Separator Description
CNT_ROOT — Cluster/system root dir (loads config.yaml + data dirs; replaces bin/ heuristic)
CNT_EXTRA_ROOT — Group/lab root dir (single path; loads config.yaml + data dirs)
CNT_EXTRA_IMAGE_DIRS | Extra image directories; entries support :ro/:rw
CNT_EXTRA_BUILD_DIRS | or : Extra build-scripts directories
CNT_EXTRA_HELPER_DIRS | Extra helper-scripts directories; entries support :ro/:rw
CNT_EXTRA_SCRIPTS_LINKS | Extra remote build script source URLs
CNT_CHANNELS | or : Conda channels
CNT_NOTIFICATION — Override notification for the current session (e.g. bell, email, ntfy.sh topic)
CNT_PROXY_PERJOB — Override proxy_perjob for the current invocation (1 = enable)
CNT_TMPDIR — Override build temp directory
SCRATCH — HPC scratch directory ($SCRATCH/condatainer/)
XDG_DATA_HOME / XDG_CONFIG_HOME / XDG_STATE_HOME — XDG base dirs

Configuration File

Location: ~/.config/condatainer/config.yaml

apptainer_bin: "apptainer"
scheduler_bin: ""         # auto-detect if empty

prefer_remote: false
default_distro: "ubuntu24"
parse_module_load: false

# Extra directories — team/lab use via module file or config
extra_image_dirs:
  - "/shared/lab/images:ro"   # search-only shared store
  - "/fast/scratch/images"    # writable personal store
extra_build_dirs:
  - "/shared/lab/scripts"
extra_helper_dirs:
  - "/shared/lab/helpers"
# For a group/lab root with standard layout (images/, build-scripts/, etc.),
# set CNT_EXTRA_ROOT=/proj/condatainer in the module file instead.

channels:
  - conda-forge
  - bioconda

build:
  ncpus: 4
  mem: 8192   # MB
  time: "2h"
  compress_args: ""   # auto-detect: zstd-medium (apptainer>=1.4), lz4 (older), gzip (singularity)

Constants

  • VERSION - Current version
  • GitHubRepo - GitHub repository (Justype/condatainer)
  • PrebuiltBaseURL - Prebuilt image download URL

Documentation

Index

Constants

View Source
const ConfigFilename = "config"

ConfigFilename is the name of the config file

View Source
const ConfigType = "yaml"

ConfigType is the type of config file (yaml, json, toml)

View Source
const DEFAULT_DISTRO = "ubuntu24"
View Source
const DefaultScriptsLink = "https://raw.githubusercontent.com/Justype/cnt-scripts/main"

DefaultScriptsLink is the base URL for remote build scripts and helpers

View Source
const ExitCodeJobsSubmitted = 3

ExitCodeJobsSubmitted is returned by condatainer commands when build jobs are submitted to the scheduler rather than run immediately. Callers (e.g. helper overlay checks) can detect this exit code to show a more helpful message.

View Source
const GITHUB_REPO = GitHubRepo // Exported constant for compatibility
View Source
const GitHubRepo = "Justype/condatainer"
View Source
const VERSION = "1.4.1"

Variables

View Source
var BlockSizeCompletions = []string{"64k", "128k", "256k", "512k", "1m"}

BlockSizeCompletions lists common mksquashfs block sizes for shell completion

View Source
var CompressOptions = []CompressOption{
	{"gzip", "-comp gzip", "Use gzip compression"},
	{"lz4", "-comp lz4", "Use lz4 compression"},
	{"zstd", "-comp zstd -Xcompression-level 14", "Use zstd compression level 14"},
	{"zstd-fast", "-comp zstd -Xcompression-level 3", "Use zstd compression level 3"},
	{"zstd-medium", "-comp zstd -Xcompression-level 8", "Use zstd compression level 8"},
	{"zstd-high", "-comp zstd -Xcompression-level 19", "Use zstd compression level 19"},
}

CompressOptions lists all supported compression shorthand names.

Functions

func ArgsForCompress added in v1.2.0

func ArgsForCompress(name string) string

ArgsForCompress returns the full mksquashfs arguments corresponding to a recognised shortcut name. Return itself if no match found.

func AutoDetectCompression

func AutoDetectCompression(supportsZstd bool, isSingularity bool)

AutoDetectCompression sets compression based on the runtime binary and its version. This should be called after apptainer version is known. supportsZstd: whether the current apptainer version supports zstd (>= 1.4) isSingularity: whether the binary is Singularity (uses gzip by default)

func BaseImageSifName added in v1.2.0

func BaseImageSifName() string

BaseImageSifName returns the expected .sif filename for the configured DefaultDistro. e.g. "ubuntu24" → "ubuntu24--base_image.sif"

func CompressNames added in v1.2.0

func CompressNames() []string

CompressNames returns a list of the shortcut names (used for completion)

func DeleteConfigKey added in v1.4.0

func DeleteConfigKey(path, key string) error

DeleteConfigKey removes a key from the config file at path. Nested keys (e.g. "build.compress_args") are handled by navigating the settings map. If removing a nested key leaves the parent empty, the parent is removed too.

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 DirExists

func DirExists(path string) bool

DirExists checks if a directory exists and is a directory.

func FilterDirsByLayer added in v1.5.1

func FilterDirsByLayer(dirs []string, layer DataLayer) []string

FilterDirsByLayer returns the subset of dirs belonging to layer, preserving order.

func FindBaseImage

func FindBaseImage() string

FindBaseImage searches all image paths for the base image. Returns the full path if found, empty string otherwise.

func FindHelperScript

func FindHelperScript(name string) (string, error)

FindHelperScript searches all helper script paths for a script by name. Returns the full path to the script if found.

func FindImage

func FindImage(name string) (string, error)

FindImage searches all image paths for an image by name. Returns the full path to the image if found.

func GetAvailableDistros added in v1.2.0

func GetAvailableDistros() []string

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 GetBaseImageWritePath

func GetBaseImageWritePath() (string, error)

GetBaseImageWritePath returns the path where a new base image should be written.

func GetBuildScriptSearchPaths

func GetBuildScriptSearchPaths() []string

GetBuildScriptSearchPaths returns all paths to search for build scripts.

func GetCacheSearchPaths added in v1.4.0

func GetCacheSearchPaths() []string

GetCacheSearchPaths returns all personal cache directories to search. Cache is always the personal XDG cache dir to avoid cross-user pollution.

func GetChannels added in v1.3.0

func GetChannels() []string

GetChannels returns the conda channels from config or environment. CNT_CHANNELS supports "|" and ":" as separators ("|" takes precedence). Overwrite semantics: if set in config, highest-priority layer wins (no merge).

func GetConfigPathByLayer added in v1.5.1

func GetConfigPathByLayer(layer string) (string, error)

GetConfigPathByLayer returns the config path for the specified config layer. Supported layers: "user"/"u", "app-root"/"root"/"r", "extra-root"/"e", "system"/"s"

func GetExtraBuildDirs added in v1.4.0

func GetExtraBuildDirs() []string

GetExtraBuildDirs returns explicit extra build-scripts directories from config or environment. CNT_EXTRA_BUILD_DIRS supports "|" and ":" as separators ("|" takes precedence).

func GetExtraHelperDirs added in v1.4.0

func GetExtraHelperDirs() []string

GetExtraHelperDirs returns explicit extra helper-scripts directories from config or environment. CNT_EXTRA_HELPER_DIRS uses "|" as separator; entries support ":ro"/":rw" markers.

func GetExtraImageDirs added in v1.4.0

func GetExtraImageDirs() []string

GetExtraImageDirs returns explicit extra image directories from config or environment. CNT_EXTRA_IMAGE_DIRS uses "|" as separator; entries support ":ro"/":rw" markers.

func GetExtraRootConfigPath added in v1.4.0

func GetExtraRootConfigPath() string

GetExtraRootConfigPath returns the extra-root config path ($CNT_EXTRA_ROOT/config.yaml). Returns empty string if CNT_EXTRA_ROOT is not set.

func GetExtraRootDir added in v1.4.0

func GetExtraRootDir() string

GetExtraRootDir returns the extra root directory from CNT_EXTRA_ROOT env var. Single value, env only (no config key). Used for group/lab shared installations. Returns empty string if not set. Cached via sync.Once.

func GetExtraScriptsLinks() []string

GetExtraScriptsLinks returns extra remote build script source URLs. CNT_EXTRA_SCRIPTS_LINKS uses "|" as separator (URLs contain "://").

func GetFileBookmarksPath added in v1.5.1

func GetFileBookmarksPath() string

GetFileBookmarksPath returns the path to the JSON file storing the dashboard's file-browser bookmarks. Path: ~/.local/state/condatainer/file-bookmarks.json

func GetHelperBookmarksPath added in v1.5.1

func GetHelperBookmarksPath() string

GetHelperBookmarksPath returns the path to the JSON file storing the dashboard's bookmarked (starred) helper names. Path: ~/.local/state/condatainer/helper-bookmarks.json

func GetHelperHistoryPath added in v1.5.0

func GetHelperHistoryPath() string

GetHelperHistoryPath returns the path to the JSONL helper run history file. Path: ~/.local/state/condatainer/helper-history.jsonl

func GetHelperScriptSearchPaths

func GetHelperScriptSearchPaths() []string

GetHelperScriptSearchPaths returns all paths to search for helper scripts.

func GetHelperStateDir added in v1.5.0

func GetHelperStateDir(id string) string

GetHelperStateDir returns the per-ID helper state directory on NFS. Each helper run writes its ready/messages/done files under this path. Path: ~/.local/state/condatainer/helper/{id}/

func GetImageSearchPaths

func GetImageSearchPaths() []string

GetImageSearchPaths returns all paths to search for images.

func GetLoadedConfigPaths added in v1.4.0

func GetLoadedConfigPaths() []string

GetLoadedConfigPaths returns the file paths of all config files actually loaded by InitViper, in priority order. These are the files that actively contribute to the effective configuration (via scalar precedence + array merging).

func GetRootConfigPath added in v1.4.0

func GetRootConfigPath() string

GetRootConfigPath returns the root config path (CNT_ROOT or standalone layout). Returns empty string if the root dir is not set.

func GetRootDir added in v1.4.0

func GetRootDir() string

GetRootDir returns the installation root directory. CNT_ROOT env var takes priority; otherwise auto-detected from the executable location.

Detection logic:

  1. CNT_ROOT env var — explicit root (set by sysadmin in module file)
  2. Executable in <dir>/bin/ and <dir> is not a standard user/system parent → use <dir>

Cached via sync.Once.

func GetRunningServerPort added in v1.5.0

func GetRunningServerPort() int

GetRunningServerPort returns the port of the currently running server on this host, reading it directly from the PID file. Returns 0 if the server is not running.

func GetSchedulerTypeFromBin

func GetSchedulerTypeFromBin(binPath string) string

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 GetServerLogPath added in v1.5.0

func GetServerLogPath() string

GetServerLogPath returns the path to the server log file for the current host. Path: ~/.local/state/condatainer/server-{hostname}.log

func GetServerLogPathForHost added in v1.5.0

func GetServerLogPathForHost(host string) string

GetServerLogPathForHost returns the path to the server log file for the given host. Path: ~/.local/state/condatainer/server-{host}.log Since the state dir is on NFS, this works for any login node.

func GetServerPidFilePath added in v1.5.0

func GetServerPidFilePath() string

GetServerPidFilePath returns the path to the server PID/state file for the current host. Path: ~/.local/state/condatainer/server-{hostname}.pid Per-host files allow NFS home dirs shared across login nodes without conflicts.

func GetServerSavedPortPath added in v1.5.0

func GetServerSavedPortPath() string

GetServerSavedPortPath returns the path to the shared saved-port file. Path: ~/.local/state/condatainer/server.port Written by "server start --port" so the same port is reused on subsequent starts across all login nodes.

func GetSystemConfigPath

func GetSystemConfigPath() string

GetSystemConfigPath returns the system-wide config path

func GetUserCacheDir added in v1.3.0

func GetUserCacheDir() string

GetUserCacheDir returns the user's cache directory following XDG spec. Returns $XDG_CACHE_HOME/condatainer or ~/.cache/condatainer

func GetUserConfigDir added in v1.5.0

func GetUserConfigDir() string

GetUserConfigDir returns the user's config directory following XDG spec. Returns $XDG_CONFIG_HOME/condatainer or ~/.config/condatainer

func GetUserConfigPath

func GetUserConfigPath() (string, error)

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 GetUserStateDir added in v1.1.1

func GetUserStateDir() string

GetUserStateDir returns the user's state directory following XDG spec. Returns $XDG_STATE_HOME/condatainer or ~/.local/state/condatainer

func GetWritableCacheDir added in v1.3.0

func GetWritableCacheDir() (string, error)

GetWritableCacheDir returns the writable personal cache directory ($XDG_CACHE_HOME/condatainer or ~/.cache/condatainer) — never a shared dir.

func GetWritableHelperScriptsDir

func GetWritableHelperScriptsDir() (string, error)

GetWritableHelperScriptsDir returns the first writable helper scripts directory. Explicit extra_helper_dirs entries marked :ro are skipped. Shared dirs (extra_helper_dirs, CNT_EXTRA_ROOT, root) are probed only. Personal dirs (scratch, user) are created on first use.

func GetWritableImagesDir

func GetWritableImagesDir() (string, error)

GetWritableImagesDir returns the first writable images directory. Explicit extra_image_dirs entries marked :ro are skipped. Shared dirs (extra_image_dirs, CNT_EXTRA_ROOT, root) are probed only. Personal dirs (scratch, user) are created on first use.

func GetWritableTmpDir

func GetWritableTmpDir() string

GetWritableTmpDir returns the first writable tmp directory. Uses the same SearchDir + firstWritableDir logic as the other writable-dir resolvers: shared dirs (extra-root, root) create tmp only when the parent already exists; personal dirs (scratch, user) always create on first use.

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 (CNT_*) — always replaces for that key 3. User config file (~/.config/condatainer/config.yaml) 4. Extra root config ($CNT_EXTRA_ROOT/config.yaml, group/lab layer) 5. Root config ($CNT_ROOT/config.yaml or <install>/config.yaml) 6. System config file (/etc/condatainer/config.yaml) 7. Defaults

Scalar keys: highest-priority config file that sets the key wins. Array keys (extra_*_dirs, extra_scripts_links): merged across all config layers so that e.g. a sysadmin's extra_image_dirs in system config are visible to users who also have their own config. channels is an exception — overwrite, not merge.

func IsInsideContainer

func IsInsideContainer() bool

IsInsideContainer checks if we're currently running inside a container

func IsValidBlockSize added in v1.3.0

func IsValidBlockSize(size string) bool

IsValidBlockSize validates a mksquashfs -b value. Must be a power of two between 4096 and 1048576 (1M), with optional k/K or m/M suffix.

func IsValidDistro added in v1.2.0

func IsValidDistro(distro string) bool

IsValidDistro returns true if the provided name matches one of the known distro slugs.

func ListServerPidFiles added in v1.5.0

func ListServerPidFiles() []string

ListServerPidFiles returns paths to all server-*.pid files in the user state directory. Each file corresponds to a login node that may have (or have had) a server running. On NFS home dirs shared across login nodes, this reveals servers on other nodes.

func LoadDefaults

func LoadDefaults(executablePath string)

func LoadFromViper

func LoadFromViper()

LoadFromViper loads config from Viper into Global struct

func NormalizeCompressArgs added in v1.2.0

func NormalizeCompressArgs(val string) string

NormalizeCompressArgs is a thin wrapper around ArgsForCompress and exists for historical compatibility with earlier versions of the code.

func NormalizeConfigLayer added in v1.5.1

func NormalizeConfigLayer(layer string) string

NormalizeConfigLayer expands a config layer shorthand to its full name. Returns the full name ("user", "app-root", "extra-root", "system") or the input unchanged. "root" and "r" are accepted as aliases for "app-root".

func ParseDirEntry added in v1.4.0

func ParseDirEntry(entry string) (string, bool)

ParseDirEntry splits a dir entry ("path", "path:ro", or "path:rw") into (path, readOnly). :ro = force search-only (never written). :rw = explicit writable annotation (same as no marker). Default (no marker) is writable if filesystem perms allow — matches all other dir types.

func ReadConfigAllKeys added in v1.4.0

func ReadConfigAllKeys(path string) []string

ReadConfigAllKeys returns all keys explicitly set in the config file at path.

func ReadConfigKey added in v1.4.0

func ReadConfigKey(configPath, key string) string

ReadConfigKey reads a single key from a config file without touching global viper state. Returns "" if the file doesn't exist, can't be read, or the key is not set.

func ReadConfigSliceKey added in v1.4.0

func ReadConfigSliceKey(configPath, key string) []string

ReadConfigSliceKey reads a string-slice key from a config file without touching global viper state. Returns nil if the file doesn't exist or the key is not set.

func ReadSavedServerPort added in v1.5.0

func ReadSavedServerPort() int

ReadSavedServerPort reads the port saved by a previous "server start --port" call. Returns 0 if no port has been saved or the file cannot be read.

func ResolveReadableConfigPath added in v1.4.0

func ResolveReadableConfigPath(layer string) (path, layerType string, err error)

ResolveReadableConfigPath resolves a config layer name to a config file path for reading. Unlike ResolveWritableConfigPath it does not check write permissions.

func ResolveWritableConfigPath added in v1.4.0

func ResolveWritableConfigPath(layer string) (path, layerType string, err error)

ResolveWritableConfigPath determines where a config-mutating command should write. If layer is non-empty it is resolved and checked for writability. If layer is empty the active config file is used when writable; otherwise falls back to the user config path, mirroring the config init smart-default behaviour.

Writability is checked on the config file itself, not just its directory: a read-only file in a writable directory (a frozen shared config) must not be treated as a valid write target.

func ResolveWritableConfigPathVerbose added in v1.5.1

func ResolveWritableConfigPathVerbose(layer string) (path, layerType, fellBackFrom string, err error)

ResolveWritableConfigPathVerbose is ResolveWritableConfigPath plus the layer it fell back from. fellBackFrom is empty unless an active config existed but was read-only, forcing the write down to the user layer — callers report that, since the change then applies only to the current user.

func SaveMinimalConfigTo added in v1.4.0

func SaveMinimalConfigTo(path, apptainerBin, schedulerBin, compressArgs string, lowerLayers []ConfigLayerInfo) error

SaveMinimalConfigTo writes only detected keys to path using a fresh viper instance, so no default values bleed in. Keys already provided by lowerLayers are skipped.

func SaveServerPort added in v1.5.0

func SaveServerPort(port int) error

SaveServerPort writes port to the shared saved-port file so it is reused on subsequent "server start" calls without --port.

func SetConfigKey added in v1.4.0

func SetConfigKey(path, key, value string) error

SetConfigKey sets a single key in the config file at path, creating it if needed. Existing keys are preserved. No-op if the file already has the key set to the same value.

func UpdateConfigKey added in v1.4.0

func UpdateConfigKey(path, key string, value any) error

UpdateConfigKey reads path into a fresh viper instance, updates key to value, and writes the result back to path. No global viper state is affected. Creates the directory and file if needed (first-use creation).

func ValidateBinary

func ValidateBinary(binPath string) bool

ValidateBinary checks if a binary exists and is executable

Types

type BuildConfig

type BuildConfig struct {
	Defaults      scheduler.ResourceSpec // Default resource spec for build job submissions
	TmpSizeMB     int                    // Size of temporary overlay in MB
	CompressArgs  string                 // mksquashfs compression arguments
	BlockSize     string                 // mksquashfs block size for app/env/external overlays (default: 128k)
	DataBlockSize string                 // mksquashfs block size for data/ref overlays (default: 1m)
	UseTmpOverlay bool                   // Use a temporary overlay instead of a temp directory (default: false)
	AlwaysSubmit  bool                   // Always submit builds as scheduler jobs even without script directives (default: false)
	Channels      []string               // conda channels in priority order (default: [conda-forge, bioconda])
}

BuildConfig holds default settings for build operations

type CompressOption added in v1.2.0

type CompressOption struct {
	Name        string // e.g. "lz4" or "zstd-fast"
	Args        string // full mksquashfs arguments
	Description string // help text for CLI
}

CompressOption defines name, mksquashfs arguments, and description

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)

	// Base OS overlay slug (e.g. "ubuntu24"). Determines the base image filename:
	// "ubuntu24" → "ubuntu24--base_image.sif". Defaults to "ubuntu24".
	DefaultDistro string

	// Remote repository settings
	ScriptsLink  string   // Base remote URL (scripts_link config key; lowest priority)
	ScriptsLinks []string // Effective ordered list: [extra_scripts_links..., scripts_link]
	PreferRemote bool     // Remote build scripts take precedence over local

	// Dependency parsing
	ParseModuleLoad bool // Parse "module load" / "ml" lines as dependencies (default: false)

	// AutoloadGPU: if true (default), detect NVIDIA/ROCm GPUs on the host and
	// automatically add --nv/--rocm to the apptainer invocation. When false,
	// GPU detection is skipped entirely and neither flag is added.
	AutoloadGPU bool

	// Scheduler command timeout (default: 0 = no timeout).
	SchedulerTimeout time.Duration

	// Notification method when a helper job starts running (default: "web").
	// Values: "web" (browser notification via dashboard), "terminal" (bell ×2, 1.1 s apart),
	// "both" (terminal + web), "" or "none" (silent).
	Notification string

	// Max age of the on-disk remote build script metadata cache (default: 1 week)
	MetadataCacheTTL time.Duration

	// ProxyPerJob: if true, inject "condatainer proxy start --via <login-node>" at the
	// top of every generated scheduler script so the compute node starts a per-job proxy.
	ProxyPerJob bool

	// HelperBindAll: if true, helper services bind to 0.0.0.0 and the server connects
	// via direct TCP instead of SSH tunnel (for clusters where inter-node SSH is blocked).
	HelperBindAll bool

	// Build configuration
	Build BuildConfig
}

Config holds global application settings

var Global Config

Global holds the singleton configuration instance

type ConfigLayerInfo added in v1.4.0

type ConfigLayerInfo struct {
	Path string
	Type string // "user", "extra-root", "root", "system"
	// contains filtered or unexported fields
}

ConfigLayerInfo exposes one loaded config layer for per-layer display.

func GetConfigLayerInfos added in v1.4.0

func GetConfigLayerInfos() []ConfigLayerInfo

GetConfigLayerInfos returns all loaded config layers in priority order. Used by config show --sources to display per-layer value annotations.

func (ConfigLayerInfo) GetBool added in v1.5.0

func (l ConfigLayerInfo) GetBool(key string) bool

GetBool returns the bool value of key from this config layer.

func (ConfigLayerInfo) GetString added in v1.4.0

func (l ConfigLayerInfo) GetString(key string) string

GetString returns the string value of key from this config layer.

func (ConfigLayerInfo) GetStringSlice added in v1.4.0

func (l ConfigLayerInfo) GetStringSlice(key string) []string

GetStringSlice returns the string slice value of key from this config layer.

func (ConfigLayerInfo) InConfig added in v1.4.0

func (l ConfigLayerInfo) InConfig(key string) bool

InConfig reports whether key is explicitly set in this config file (not just a default).

type ConfigSearchPath

type ConfigSearchPath struct {
	Path   string // Full path to config file
	Type   string // Type: "root", "extra-root", "user", "system"
	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. InUse is true for every config file that was loaded (all contribute via merging), not just the primary. Duplicate paths (e.g. CNT_EXTRA_ROOT == CNT_ROOT) are skipped.

type DataLayer added in v1.5.1

type DataLayer string

DataLayer identifies which tier a data directory belongs to. The short forms (u/r/e) match the -l/--layer vocabulary used by the config commands, so a single mental model covers both config files and data directories.

const (
	LayerExtra     DataLayer = "extra"      // extra_*_dirs config keys (no short form)
	LayerExtraRoot DataLayer = "extra-root" // $CNT_EXTRA_ROOT           (e)
	LayerAppRoot   DataLayer = "app-root"   // $CNT_ROOT or <install-dir> (r)
	LayerUser      DataLayer = "user"       // $SCRATCH, else XDG data dir (u)
)

func ClassifyDataDir added in v1.5.1

func ClassifyDataDir(path string) DataLayer

ClassifyDataDir reports which layer a data directory belongs to, by comparing its parent against each tier root. Tiers are checked in search-path order, so a directory shared by two tiers (e.g. CNT_ROOT == $SCRATCH/condatainer) is labelled with the higher-priority one, matching how lookups resolve it.

func ParseDataLayer added in v1.5.1

func ParseDataLayer(s string) (DataLayer, error)

ParseDataLayer resolves a user-supplied layer name or its short form.

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 → root → 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 SearchDir added in v1.4.0

type SearchDir struct {
	Path     string
	Personal bool
}

SearchDir is a candidate directory for write operations. Personal dirs (scratch, XDG user) are always created on first use via EnsureWritableDir. Shared dirs (CNT_EXTRA_ROOT, root, extra_*_dirs): subdirs are created if the parent exists, but the parent itself is never auto-created.

type ServerState added in v1.5.0

type ServerState struct {
	Host   string `json:"host"`
	Port   int    `json:"port"`
	Token  string `json:"token"`
	PID    int    `json:"pid"`
	Daemon bool   `json:"daemon"` // Saved for 'server restart' using same daemon mode.
}

ServerState is the JSON written to the server PID file (NFS-visible).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL