Documentation
¶
Index ¶
Constants ¶
const ( LogDebug = zerolog.DebugLevel LogInfo = zerolog.DebugLevel LogWarn = zerolog.WarnLevel LogDisabled = zerolog.Disabled )
const DefaultLogLevel = LogDisabled
DefaultLogLevel for binr is logging disabled. Use SetLogLevel to change.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(ctx context.Context, namespace, command, version string, source Source, options ...option) (path string, err error)
Get the path to a binary.
`namespace` is generally the name of the application or system which is utilizing binr. By default commands will be downloaded to this namespace within the current user's config directory (~/.config/binr/[namespace])
`command` is the name of the command to get. It is made available by default as ~/.config/binr/[namespace]/[command] and also ~/.config/binr/[namespace]/[command]-[version]
Version is the specific version to get. TODO: currently expects an exact (vX.Y.Z), but will soon support semver major and minor (vX and vX.Y).
The provided Source is a function which returns a final location at which the command and its checksum can be downloaded for a given os, architecture and version.
func Path ¶
Path returns the absolute path at which the given command for the given namespace is expected to exist. It does not validate the command's existence (see Get).
Version is optional, and if not provided will point to a "floating" link which is always updated to the current version. If provided, it must be a semver
func SetLogLevel ¶
func SetLogLevel(l logLevel)
SetLogLevel to LogDebug, LogInfo, LogWarn, or LogDisabled Errors are always returned as values.
func WithUpdate ¶
func WithUpdate() func(*config)
WithUpdate instructs the system to update extant binaries. The default behavior is to never replace a binary once it has been provided. Note that this option worls in concert with version and checksum URL. TODO: implement and document:
Has no effect if either the version is explicit (vX.Y.Z), or there is no checksum URL returned from the source implementation. If the version is omitted (aka "latest"), but a checksum URL is provided from the source implementation, WithUpdate will result in a call to .Get checking if the checksum differs from the currently cached binary, and replacing with the latest via download. If the version is provided, but is not explicit (vX.Y or vX), the source implementation should provide the checksum URL and source URL to the latest implementation which adheres to the specified semver, and the WithUpdate option causes this to be utilized.