Documentation
¶
Overview ¶
Package scan detects installed software on the current system and matches it against the Strata layer registry.
Index ¶
- Variables
- func CurrentABI() (string, error)
- func CurrentArch() string
- func LockFileFromMatches(results []MatchResult, name, osName, arch, abi string) *spec.LockFile
- func ProfileFromMatches(results []MatchResult, name, osName, arch string) *spec.Profile
- type DetectSource
- type DetectedPackage
- type ExecRunner
- type MatchResult
- type MatchStatus
- type RealExecRunner
- type Scanner
Constants ¶
This section is empty.
Variables ¶
var DefaultFSScanPaths = []string{"/opt", "/usr/local", "/opt/apps", "/opt/software"}
DefaultFSScanPaths is the default set of directories to scan for installed software.
Functions ¶
func CurrentABI ¶
CurrentABI reads /etc/os-release and maps the OS ID to an ABI string. Does NOT import internal/probe to avoid AWS coupling.
func CurrentArch ¶
func CurrentArch() string
CurrentArch maps runtime.GOARCH to "x86_64" or "arm64".
func LockFileFromMatches ¶
func LockFileFromMatches(results []MatchResult, name, osName, arch, abi string) *spec.LockFile
LockFileFromMatches builds a LockFile from StatusMatched results only. MountOrder is detection order. ResolvedAt is time.Now(). RekorEntry is empty.
func ProfileFromMatches ¶
func ProfileFromMatches(results []MatchResult, name, osName, arch string) *spec.Profile
ProfileFromMatches builds a Profile from StatusMatched results only.
Types ¶
type DetectSource ¶
type DetectSource string
DetectSource identifies how a package was found.
const ( SourceLmod DetectSource = "lmod" SourceConda DetectSource = "conda" SourcePip DetectSource = "pip" SourceFilesystem DetectSource = "filesystem" )
DetectSource constants identify where a package was found.
type DetectedPackage ¶
type DetectedPackage struct {
Name string
Version string
Prefix string // install root (empty for pip packages)
Source DetectSource
ModulefilePath string // lmod only
ModuleDeps []string // lmod prereqs
Channel string // conda only
BuildHash string // conda only
}
DetectedPackage describes a software installation found on the current system.
func DetectConda ¶
func DetectConda(_ context.Context) ([]DetectedPackage, error)
DetectConda discovers conda environments and returns installed packages. Silently returns empty if conda is not installed or no environments are found.
func DetectFilesystem ¶
func DetectFilesystem(_ context.Context, scanPaths []string) ([]DetectedPackage, error)
DetectFilesystem scans configured paths for <name>/<version>/ layout packages. It looks two levels deep and classifies directories as packages if they contain a bin/ or lib/ subdirectory and the version matches a numeric pattern.
func DetectLmod ¶
func DetectLmod(_ context.Context) ([]DetectedPackage, error)
DetectLmod walks $MODULEPATH and returns detected packages. Silently returns empty if MODULEPATH is not set.
func DetectPip ¶
func DetectPip(ctx context.Context, runner ExecRunner) ([]DetectedPackage, error)
DetectPip detects pip-installed packages using the provided ExecRunner. Silently returns empty if python3 or pip is not available.
type ExecRunner ¶
type ExecRunner interface {
Output(ctx context.Context, name string, args ...string) ([]byte, error)
}
ExecRunner is injectable for testing.
type MatchResult ¶
type MatchResult struct {
Package DetectedPackage
Status MatchStatus
Manifest *spec.LayerManifest // non-nil for Matched/NearMatch
NearVersion string // nearest version (NearMatch only)
}
MatchResult pairs a detected package with its registry match status.
func MatchAll ¶
func MatchAll(ctx context.Context, reg registry.Client, pkgs []DetectedPackage, arch, abi string) ([]MatchResult, error)
MatchAll matches detected packages against a registry. Name comparison: case-insensitive, hyphen/underscore equivalent (pip normalization). Version comparison: exact string match. Results are in the same order as pkgs.
type MatchStatus ¶
type MatchStatus string
MatchStatus describes how a DetectedPackage matched the registry.
const ( StatusMatched MatchStatus = "matched" // exact name+version in registry StatusNearMatch MatchStatus = "near_match" // name found, different version StatusUnmatched MatchStatus = "unmatched" // name not in registry )
MatchStatus constants indicate how well a detected package matched the registry.
type Scanner ¶
type Scanner struct {
LmodEnabled bool
CondaEnabled bool
PipEnabled bool
FSEnabled bool
FSScanPaths []string
Exec ExecRunner // nil → RealExecRunner
}
Scanner detects installed software from multiple sources.
func NewScanner ¶
func NewScanner() *Scanner
NewScanner returns a Scanner with all standard sources enabled (FSEnabled=false).