Documentation
¶
Index ¶
- func CompareVersions(installed, required string, mode VersionCheckMode) (bool, error)
- func ExtractVersionFromOutput(output, pattern string) (string, error)
- func GetInstalledVersion(binaryPath string, dependency *Dependency) (string, error)
- func GetInstalledVersionByCommand(command string, dependency *Dependency) (string, error)
- func Install(name, version string, opts ...InstallOption) error
- func InstallDependencies(deps map[string]string, binDir string) error
- func InstallDependency(name, ver string, binDir string) error
- func Which(cmd string) bool
- type BinaryFunc
- type BinaryFuncWithEnv
- type Dependency
- type InstallOption
- func WithBinDir(dir string) InstallOption
- func WithForce(force bool) InstallOption
- func WithOS(goos, goarch string) InstallOption
- func WithPreferLocal(prefer bool) InstallOption
- func WithSkipChecksum(skip bool) InstallOption
- func WithTimeout(timeout time.Duration) InstallOption
- func WithVersionCheck(mode VersionCheckMode) InstallOption
- type InstallOptions
- type Process
- type VersionCheckMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶ added in v1.42.2
func CompareVersions(installed, required string, mode VersionCheckMode) (bool, error)
CompareVersions compares two version strings using semver
func ExtractVersionFromOutput ¶ added in v1.42.2
ExtractVersionFromOutput extracts version using regex pattern
func GetInstalledVersion ¶ added in v1.42.2
func GetInstalledVersion(binaryPath string, dependency *Dependency) (string, error)
GetInstalledVersion extracts version from binary output
func GetInstalledVersionByCommand ¶ added in v1.42.2
func GetInstalledVersionByCommand(command string, dependency *Dependency) (string, error)
GetInstalledVersionByCommand extracts version by running command directly
func Install ¶ added in v1.42.2
func Install(name, version string, opts ...InstallOption) error
Install installs a dependency with configurable options
func InstallDependencies ¶
InstallDependencies takes a map of supported dependencies and their version and installs them to the specified binDir
func InstallDependency ¶
InstallDependency installs a binary to binDir, if ver is nil then the default version is used
Types ¶
type BinaryFunc ¶
BinaryFunc is an interface to executing a binary, downloading it necessary
func Binary ¶
func Binary(name, ver string, binDir string) BinaryFunc
Binary returns a function that can be called to execute the binary
func BinaryWithEnv ¶
func BinaryWithEnv(name, ver string, binDir string, env map[string]string) BinaryFunc
BinaryWithEnv returns a function that be called to execute the binary
func BinaryWithOptions ¶ added in v1.42.2
func BinaryWithOptions(name, ver string, opts ...InstallOption) BinaryFunc
BinaryWithOptions returns a function that can be called to execute the binary with configurable options
type BinaryFuncWithEnv ¶
BinaryFuncWithEnv is an interface to executing a binary, downloading it necessary
type Dependency ¶
type Dependency struct {
Version string
Linux string
LinuxARM string
Macosx string
MacosxARM string
Windows string
Go string
Docker string
Template string
BinaryName string
PreInstalled []string
VersionCommand string // Command to get version (e.g., "--version")
VersionPattern string // Regex pattern to extract version from output
Checksums map[string]string // Platform -> checksum mapping
}
Dependency is a struct referring to a version and the templated path to download the dependency on the different OS platforms
func (*Dependency) GetPath ¶ added in v1.5.15
func (dependency *Dependency) GetPath(name string, binDir string) (string, error)
func (*Dependency) GetPathWithOptions ¶ added in v1.42.2
func (dependency *Dependency) GetPathWithOptions(name string, binDir string, goos, goarch string) (string, error)
GetPathWithOptions returns the binary path using specified OS and architecture
type InstallOption ¶ added in v1.42.2
type InstallOption func(*InstallOptions)
InstallOption is a functional option for configuring installation
func WithBinDir ¶ added in v1.42.2
func WithBinDir(dir string) InstallOption
WithBinDir sets the binary installation directory
func WithForce ¶ added in v1.42.2
func WithForce(force bool) InstallOption
WithForce enables or disables forced reinstallation
func WithOS ¶ added in v1.42.2
func WithOS(goos, goarch string) InstallOption
WithOS overrides the target OS and architecture
func WithPreferLocal ¶ added in v1.42.2
func WithPreferLocal(prefer bool) InstallOption
WithPreferLocal prefers locally installed binaries over downloading
func WithSkipChecksum ¶ added in v1.42.2
func WithSkipChecksum(skip bool) InstallOption
WithSkipChecksum enables or disables checksum verification
func WithTimeout ¶ added in v1.42.2
func WithTimeout(timeout time.Duration) InstallOption
WithTimeout sets the download timeout
func WithVersionCheck ¶ added in v1.42.2
func WithVersionCheck(mode VersionCheckMode) InstallOption
WithVersionCheck sets the version checking mode
type InstallOptions ¶ added in v1.42.2
type InstallOptions struct {
BinDir string
Force bool
VersionCheck VersionCheckMode
GOOS string
GOARCH string
Timeout time.Duration
SkipChecksum bool
PreferLocal bool
}
InstallOptions configures the installation behavior
type VersionCheckMode ¶ added in v1.42.2
type VersionCheckMode int
VersionCheckMode defines how version checking should be performed
const ( // VersionCheckNone skips version checking entirely VersionCheckNone VersionCheckMode = iota // VersionCheckExact requires an exact version match VersionCheckExact // VersionCheckMinimum requires the installed version to be at least the specified version VersionCheckMinimum // VersionCheckCompatible allows compatible versions (same major version) VersionCheckCompatible )