Documentation
¶
Index ¶
- Constants
- Variables
- func MaybeExec(args []string, currentVersion string, cwd string, exit func(int)) error
- func MaybeExecWithSystem(sys System, args []string, currentVersion string, cwd string, exit func(int)) error
- func PrefetchVersion(versionInput string, progressOut io.Writer) error
- type RealSystem
- func (RealSystem) Environ() []string
- func (RealSystem) ExecBinary(path string, args []string, env []string, exit func(int)) error
- func (RealSystem) FindAgentLayerRoot(start string) (string, bool, error)
- func (RealSystem) Getenv(key string) string
- func (RealSystem) ReadFile(name string) ([]byte, error)
- func (RealSystem) Stderr() io.Writer
- func (RealSystem) UserCacheDir() (string, error)
- type System
Constants ¶
const ( EnvCacheDir = "AL_CACHE_DIR" EnvNoNetwork = "AL_NO_NETWORK" EnvVersionOverride = "AL_VERSION" EnvShimActive = "AL_SHIM_ACTIVE" )
EnvCacheDir, EnvNoNetwork, EnvVersionOverride, and EnvShimActive define dispatch environment keys.
Variables ¶
var ErrDispatched = errors.New(messages.DispatchErrDispatched)
ErrDispatched signals that execution has been handed off to another binary.
Functions ¶
func MaybeExec ¶
MaybeExec checks for a pinned version and dispatches to it when needed. It returns ErrDispatched if execution was handed off.
func MaybeExecWithSystem ¶ added in v0.5.7
func MaybeExecWithSystem(sys System, args []string, currentVersion string, cwd string, exit func(int)) error
MaybeExecWithSystem checks for a pinned version and dispatches to it when needed. It returns ErrDispatched if execution was handed off.
func PrefetchVersion ¶ added in v0.8.0
PrefetchVersion ensures the requested release binary is cached locally. It validates the version, resolves the cache root, downloads the binary when missing, and writes download progress to progressOut.
Types ¶
type RealSystem ¶ added in v0.5.7
type RealSystem struct{}
RealSystem implements System using the OS and root finder.
func (RealSystem) Environ ¶ added in v0.5.7
func (RealSystem) Environ() []string
Environ returns a copy of strings representing the environment.
func (RealSystem) ExecBinary ¶ added in v0.5.7
ExecBinary replaces the current process with the provided binary.
func (RealSystem) FindAgentLayerRoot ¶ added in v0.5.7
func (RealSystem) FindAgentLayerRoot(start string) (string, bool, error)
FindAgentLayerRoot searches upwards from start for an .agent-layer directory.
func (RealSystem) Getenv ¶ added in v0.5.7
func (RealSystem) Getenv(key string) string
Getenv returns the value of the environment variable named by key.
func (RealSystem) ReadFile ¶ added in v0.5.7
func (RealSystem) ReadFile(name string) ([]byte, error)
ReadFile reads the named file and returns the contents.
func (RealSystem) Stderr ¶ added in v0.7.0
func (RealSystem) Stderr() io.Writer
Stderr returns the standard error writer.
func (RealSystem) UserCacheDir ¶ added in v0.5.7
func (RealSystem) UserCacheDir() (string, error)
UserCacheDir returns the default user cache directory.
type System ¶ added in v0.5.7
type System interface {
UserCacheDir() (string, error)
ReadFile(name string) ([]byte, error)
Getenv(key string) string
Environ() []string
ExecBinary(path string, args []string, env []string, exit func(int)) error
FindAgentLayerRoot(start string) (string, bool, error)
Stderr() io.Writer
}
System abstracts OS operations needed by version dispatch. This interface is intentionally package-local per Decision edefea6 to enable parallel-safe unit tests without shared global state. Other packages (install, sync) define their own System interfaces with operations specific to their needs.