version

package
v1.203.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

func ValidateConstraint(constraintStr string) (bool, error)

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 ExecFunc added in v1.203.0

type ExecFunc func(argv0 string, argv []string, envv []string) error

ExecFunc is the function signature for syscall.Exec.

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

type VersionInstaller interface {
	Install(toolSpec string, force, allowPrereleases bool) error
}

VersionInstaller is an interface for installing atmos versions.

Jump to

Keyboard shortcuts

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