Documentation
¶
Index ¶
- Constants
- Variables
- func CheckAndReexec(atmosConfig *schema.AtmosConfiguration) bool
- func CheckAndReexecWithConfig(atmosConfig *schema.AtmosConfiguration, cfg *ReexecConfig) bool
- func ValidateConstraint(constraintStr string) (bool, error)
- type ExecFunc
- type ReexecConfig
- type VersionFinder
- type VersionInstaller
Constants ¶
const ( // ReexecGuardEnvVar prevents infinite re-exec loops. ReexecGuardEnvVar = "ATMOS_REEXEC_GUARD" // VersionEnvVar is the environment variable for specifying the Atmos version to use. // This is a convenience alias that matches common conventions (e.g., tfenv, goenv). VersionEnvVar = "ATMOS_VERSION" // VersionUseEnvVar is the environment variable for specifying the Atmos version. // This matches the config path `version.use` in atmos.yaml. // The --use-version flag also sets this env var. VersionUseEnvVar = "ATMOS_VERSION_USE" )
Variables ¶
var Version = "test" // Default version; will be overridden during build
Version holds the current version of the Atmos CLI. It can be set dynamically during build time using ldflags.
Functions ¶
func CheckAndReexec ¶ added in v1.203.0
func CheckAndReexec(atmosConfig *schema.AtmosConfiguration) bool
CheckAndReexec checks if version.use is configured and re-executes with the specified version. This should be called after config/profiles are loaded but before command execution. Returns true if re-exec was triggered (caller should exit), false otherwise.
func CheckAndReexecWithConfig ¶ added in v1.203.0
func CheckAndReexecWithConfig(atmosConfig *schema.AtmosConfiguration, cfg *ReexecConfig) bool
CheckAndReexecWithConfig checks if version.use is configured and re-executes with the specified version. This variant accepts a ReexecConfig for testability.
func ValidateConstraint ¶ added in v1.201.0
ValidateConstraint checks if the current Atmos version satisfies the given constraint. Returns (satisfied bool, error). If constraintStr is empty, returns (true, nil).
The constraint string uses hashicorp/go-version syntax (same as Terraform):
- ">=1.2.3" - Minimum version
- "<2.0.0" - Maximum version (exclusive)
- ">=1.2.3, <2.0.0" - Range (AND logic)
- ">=2.5.0, !=2.7.0, <3.0.0" - Complex (multiple AND constraints)
- "~>1.2" - Pessimistic constraint (>=1.2.0, <1.3.0)
- "~>1.2.3" - Pessimistic constraint (>=1.2.3, <1.3.0)
- "1.2.3" - Exact version
Types ¶
type ReexecConfig ¶ added in v1.203.0
type ReexecConfig struct {
Finder VersionFinder
Installer VersionInstaller
ExecFn ExecFunc
GetEnv func(string) string
SetEnv func(string, string) error
Args []string
Environ func() []string
}
ReexecConfig holds dependencies for version re-execution.
func DefaultReexecConfig ¶ added in v1.203.0
func DefaultReexecConfig() *ReexecConfig
DefaultReexecConfig returns the default production configuration.
type VersionFinder ¶ added in v1.203.0
type VersionFinder interface {
FindBinaryPath(owner, repo, version string, binaryName ...string) (string, error)
}
VersionFinder is an interface for finding and installing atmos versions.
type VersionInstaller ¶ added in v1.203.0
VersionInstaller is an interface for installing atmos versions.