brewenv

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ConfigurationMatchFiles is a list of patterns used to match a config file for schema validation.
	ConfigurationMatchFiles = apiutil.ConfigDocumentedPath(configurationFileName)

	// ConfigurationFile is the default config file location.
	ConfigurationFile = apiutil.DefaultConfigPath(configurationFileName)

	// UnevaluatedConfigurationSearchFiles are used for display.
	UnevaluatedSearchFiles = []string{
		PrefixEnvFile(),
		filepath.Join("$XDG_CONFIG_HOME", configurationFileName),
		filepath.Join(xdg.Home, ".homebrew"),
		SystemEnvFile(),
	}
)
View Source
var (
	//revive:disable:exported
	DefaultAPIDomain               = "https://formulae.brew.sh/api"
	DefaultArch                    = "native"
	DefaultAPIAutoUpdateSecs       = 450
	DefaultAutoUpdateSecs          = 86400
	DefaultBottleDomain            = "https://ghcr.io/v2/homebrew/core"
	DefaultBrewGitRemote           = "https://github.com/Homebrew/brew"
	DefaultCache                   = filepath.Join(xdg.CacheHome, "Homebrew")
	DefaultCleanupMaxAgeDays       = 120
	DefaultCleanupPeriodicFullDays = 30
	DefaultCoreGitRemote           = "https://github.com/Homebrew/homebrew-core"
	DefaultCurlPath                = "curl"
	DefaultCurlRetries             = 3
	DefaultFailLogLines            = 15
	DefaultGitPath                 = "git"
	DefaultInstallBadge            = "🍺"
	DefaultLivecheckWatchlist      = defaultLivecheckWatchlist()
	DefaultLogs                    = defaultLogs()
	DefaultMakeJobs                = runtime.NumCPU()
	DefaultPIPIndexURL             = "https://pypi.org/simple"
	DefaultSSHConfigPath           = filepath.Join(xdg.Home, ".ssh", "config")
	DefaultSVN                     = "svn"
	DefaultTemp                    = defaultTemp()
)

Functions

func ConfigurationDefault added in v0.2.0

func ConfigurationDefault(cfg *Configuration)

ConfigurationDefault defaults the object's fields.

func ConfigurationEnvOverrides added in v0.2.0

func ConfigurationEnvOverrides(cfg *Configuration)

ConfigurationEnvOverrides overrides the configuration with environment variables.

func DefaultEnvFiles added in v0.2.0

func DefaultEnvFiles() []string

DefaultEnvironmentFiles returns the default env files in increasing priority order.

func DefaultEnvironmentFiles

func DefaultEnvironmentFiles() []string

DefaultEnvironmentFiles returns the default files to load the environment config from.

func PrefixEnvFile added in v0.2.0

func PrefixEnvFile() string

PrefixEnvFile produces the prefix env file location.

func SystemEnvFile added in v0.2.0

func SystemEnvFile() string

SystemEnvFile produces the system env file location.

func SystemEnvTakesPriority added in v0.2.0

func SystemEnvTakesPriority() bool

SystemEnvTakesPriority reports whether the HOMEBREW_SYSTEM_ENV_TAKES_PRIORITY variable is set. The setting indicates that the system env file should take priority over the prefix and user env files.

func UserEnvFile added in v0.2.0

func UserEnvFile() string

UserEnvFile produces the system env file location.

Types

type APIConfig added in v0.2.0

type APIConfig struct {
	// Domain to use for the Homebrew API. Overrides Homebrew's HOMEBREW_API_DOMAIN value.
	//
	// Default: https://formulae.brew.sh/api
	Domain string `json:"domain,omitempty" yaml:"domain,omitempty" env:"DOMAIN"`

	// Configure auto-update behavior
	AutoUpdate AutoUpdateConfig `json:"autoUpdate,omitempty" yaml:"autoUpdate,omitempty" envPrefix:"AUTO_UPDATE_"`
}

APIConfig configures Hops' usage of the Homebrew API.

type AutoUpdateConfig added in v0.2.0

type AutoUpdateConfig struct {
	Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty" env:"DISABLED"`
	Secs     *int `json:"secs,omitempty" yaml:"secs,omitempty" env:"SECS"`
}

AutoUpdateConfig configures auto-updates for a formula index.

func (*AutoUpdateConfig) ShouldAutoUpdate added in v0.2.0

func (au *AutoUpdateConfig) ShouldAutoUpdate(file string) bool

ShouldAutoUpdate returns true if an auto update should be run.

type Configuration added in v0.2.0

type Configuration struct {
	// Use this directory as the download cache.
	//
	// Defaults:
	//  - macOS: `$XDG_CACHE_HOME/Homebrew` or `$HOME/Library/Caches/Homebrew`
	//  - Linux: `$XDG_CACHE_HOME/Homebrew` or `$HOME/.cache/Homebrew`.
	Cache string `json:"cache,omitempty" yaml:"cache,omitempty" env:"CACHE"`

	// Prefix all download URLs, including those for bottles, with this value. For example, `HOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080` will cause a formula with the URL `https://example.com/foo.tar.gz` to instead download from `http://localhost:8080/https://example.com/foo.tar.gz`. Bottle URLs however, have their domain replaced with this prefix. This results in e.g. `https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21` to instead be downloaded from `http://localhost:8080/v2/homebrew/core/gettext/manifests/0.21`
	ArtifactDomain string `json:"artifactDomain,omitempty" yaml:"artifactDomain,omitempty" env:"ARTIFACT_DOMAIN"`

	// Configures Hops' usage of the Homebrew API.
	API APIConfig `json:"api,omitempty" yaml:"api,omitempty" envPrefix:"API_"`

	// Use this URL as the download mirror for bottles. If bottles at that URL are temporarily unavailable, the default bottle domain will be used as a fallback mirror. For example, setting BottleDomain to `HOMEBREW_BOTTLE_DOMAIN=http://localhost:8080` will cause all bottles to download from the prefix `http://localhost:8080/`.
	//
	// Default: `https://ghcr.io/v2/homebrew/core`.
	BottleDomain string `json:"bottleDomain,omitempty" yaml:"bottleDomain,omitempty" env:"BOTTLE_DOMAIN"`

	// Docker registry configuration
	DockerRegistry DockerRegistryConfig `json:"dockerRegistry,omitempty" yaml:"dockerRegistry,omitempty" envPrefix:"DOCKER_REGISTRY_"`
}

Configuration represents Homebrew's environment configuration. Note that environment variables must have a value set to be detected. For example, run "export HOMEBREW_NO_INSECURE_REDIRECT=1" rather than just "export HOMEBREW_NO_INSECURE_REDIRECT".

`HOMEBREW_*` environment variables can also be set in Homebrew’s environment files:

  • /etc/homebrew/brew.env (system-wide)
  • $HOMEBREW_PREFIX/etc/homebrew/brew.env` (prefix-specific)
  • $XDG_CONFIG_HOME/homebrew/brew.env if $XDG_CONFIG_HOME is set or $HOME/.homebrew/brew.env otherwise (user-specific)

User-specific environment files take precedence over prefix-specific files and prefix-specific files take precedence over system-wide files (unless `HOMEBREW_SYSTEM_ENV_TAKES_PRIORITY` is set, see below).

Note that these files do not support shell variable expansion e.g. `$HOME` or command execution e.g. `$(cat file)`.

func (*Configuration) GitHubPackagesAuth added in v0.2.0

func (e *Configuration) GitHubPackagesAuth() string

GitHubPackagesAuth derives the GitHub Packages auth from the env config.

From: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/brew.sh

func (*Configuration) GitHubPackagesHeaders added in v0.2.0

func (e *Configuration) GitHubPackagesHeaders() http.Header

GitHubPackagesHeaders derives the GitHub Packages auth from the env config.

type DockerRegistryConfig added in v0.2.0

type DockerRegistryConfig struct {
	// Use this base64 encoded username and password for authenticating with a Docker registry proxying GitHub Packages. If Token is set, it will be used instead.
	BasicAuthToken string `json:"basicAuthToken,omitempty" yaml:"basicAuthToken,omitempty" env:"BASIC_AUTH_TOKEN"`

	// Use this bearer token for authenticating with a Docker registry proxying GitHub Packages. Preferred over BasicAuthToken.
	Token string `json:"token,omitempty" yaml:"token,omitempty" env:"TOKEN"`
}

DockerRegistryConfig configures docker registry usage.

type Environment

type Environment struct {
	// HOMEBREW_PREFIX
	Prefix string `json:"HOMEBREW_PREFIX" env:"HOMEBREW_PREFIX"`

	// HOMEBREW_API_DOMAIN
	// Use this URL as the download mirror for Homebrew JSON API. If metadata files at that URL are temporarily unavailable, the default API domain will be used as a fallback mirror.
	//
	// Default: `https://formulae.brew.sh/api`.
	APIDomain string `json:"HOMEBREW_API_DOMAIN" env:"HOMEBREW_API_DOMAIN"`

	// HOMEBREW_ARTIFACT_DOMAIN
	// Prefix all download URLs, including those for bottles, with this value. For example, `HOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080` will cause a formula with the URL `https://example.com/foo.tar.gz` to instead download from `http://localhost:8080/https://example.com/foo.tar.gz`. Bottle URLs however, have their domain replaced with this prefix. This results in e.g. `https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21` to instead be downloaded from `http://localhost:8080/v2/homebrew/core/gettext/manifests/0.21`
	ArtifactDomain string `json:"HOMEBREW_ARTIFACT_DOMAIN" env:"HOMEBREW_ARTIFACT_DOMAIN"`

	// HOMEBREW_API_AUTO_UPDATE_SECS
	// Check Homebrew’s API for new formulae or cask data every `HOMEBREW_API_AUTO_UPDATE_SECS` seconds. Alternatively, disable API auto-update checks entirely with `HOMEBREW_NO_AUTO_UPDATE`.
	//
	// Default: `450`.
	APIAutoUpdateSecs int `json:"HOMEBREW_API_AUTO_UPDATE_SECS" env:"HOMEBREW_API_AUTO_UPDATE_SECS"`

	// HOMEBREW_AUTO_UPDATE_SECS
	// Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, disable auto-update entirely with `HOMEBREW_NO_AUTO_UPDATE`.
	//
	// Default: `86400` (24 hours), `3600` (1 hour) if a developer command has been run or `300` (5 minutes) if `HOMEBREW_NO_INSTALL_FROM_API` is set.
	AutoUpdateSecs int `json:"HOMEBREW_AUTO_UPDATE_SECS" env:"HOMEBREW_AUTO_UPDATE_SECS"`

	// HOMEBREW_BOTTLE_DOMAIN
	// Use this URL as the download mirror for bottles. If bottles at that URL are temporarily unavailable, the default bottle domain will be used as a fallback mirror. For example, `HOMEBREW_BOTTLE_DOMAIN=http://localhost:8080` will cause all bottles to download from the prefix `http://localhost:8080/`. If bottles are not available at `HOMEBREW_BOTTLE_DOMAIN` they will be downloaded from the default bottle domain.
	//
	// Default: `https://ghcr.io/v2/homebrew/core`.
	BottleDomain string `json:"HOMEBREW_BOTTLE_DOMAIN" env:"HOMEBREW_BOTTLE_DOMAIN"`

	// HOMEBREW_CACHE
	// Use this directory as the download cache.
	//
	// Defaults:
	//  - macOS: `$XDG_CACHE_HOME/Homebrew` or `$HOME/Library/Caches/Homebrew`
	//  - Linux: `$XDG_CACHE_HOME/Homebrew` or `$HOME/.cache/Homebrew`.
	Cache string `json:"HOMEBREW_CACHE" env:"HOMEBREW_CACHE"`

	// HOMEBREW_CLEANUP_MAX_AGE_DAYS
	// Cleanup all cached files older than this many days.
	//
	// Default: `120`.
	CleanupMaxAgeDays int `json:"HOMEBREW_CLEANUP_MAX_AGE_DAYS" env:"HOMEBREW_CLEANUP_MAX_AGE_DAYS"`

	// HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS
	// If set, `brew install`, `brew upgrade` and `brew reinstall` will cleanup all formulae when this number of days has passed.
	//
	// Default: `30`.
	CleanupPeriodicFullDays int `json:"HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS" env:"HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS"`

	// HOMEBREW_DEBUG
	// If set, always assume `--debug` when running commands.
	Debug bool `json:"HOMEBREW_DEBUG" env:"HOMEBREW_DEBUG"`

	// HOMEBREW_DEVELOPER
	// If set, tweak behaviour to be more relevant for Homebrew developers (active or budding) by e.g. turning warnings into errors.
	Developer bool `json:"HOMEBREW_DEVELOPER" env:"HOMEBREW_DEVELOPER"`

	// HOMEBREW_DOCKER_REGISTRY_BASIC_AUTH_TOKEN
	// Use this base64 encoded username and password for authenticating with a Docker registry proxying GitHub Packages. If `HOMEBREW_DOCKER_REGISTRY_TOKEN` is set, it will be used instead.
	DockerRegistryBasicAuthToken string `json:"HOMEBREW_DOCKER_REGISTRY_BASIC_AUTH_TOKEN" env:"HOMEBREW_DOCKER_REGISTRY_BASIC_AUTH_TOKEN"`

	// HOMEBREW_DOCKER_REGISTRY_TOKEN
	// Use this bearer token for authenticating with a Docker registry proxying GitHub Packages. Preferred over `HOMEBREW_DOCKER_REGISTRY_BASIC_AUTH_TOKEN`.
	DockerRegistryToken string `json:"HOMEBREW_DOCKER_REGISTRY_TOKEN" env:"HOMEBREW_DOCKER_REGISTRY_TOKEN"`

	// HOMEBREW_INSTALL_BADGE
	// Print this text before the installation summary of each successful build.
	//
	// Default: The “Beer Mug” emoji.
	InstallBadge string `json:"HOMEBREW_INSTALL_BADGE" env:"HOMEBREW_INSTALL_BADGE"`

	// HOMEBREW_NO_EMOJI
	// If set, do not print `HOMEBREW_INSTALL_BADGE` on a successful build.
	NoEmoji bool `json:"HOMEBREW_NO_EMOJI" env:"HOMEBREW_NO_EMOJI"`

	// HOMEBREW_NO_INSTALL_UPGRADE
	// If set, `brew install` **`formula|cask`** will not upgrade **`formula|cask`** if it is installed but outdated.
	NoInstallUpgrade bool `json:"HOMEBREW_NO_INSTALL_UPGRADE" env:"HOMEBREW_NO_INSTALL_UPGRADE"`

	// HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK
	// If set, do not check for broken linkage of dependents or outdated dependents after installing, upgrading or reinstalling formulae. This will result in fewer dependents (and their dependencies) being upgraded or reinstalled but may result in more breakage from running `brew install` **`formula`** or `brew upgrade` **`formula`**.
	NoInstalledDependentsCheck bool `json:"HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK" env:"HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK"`

	// HOMEBREW_NO_UPDATE_REPORT_NEW
	// If set, `brew update` will not show the list of newly added formulae/casks.
	NoUpdateReportNew bool `json:"HOMEBREW_NO_UPDATE_REPORT_NEW" env:"HOMEBREW_NO_UPDATE_REPORT_NEW"`

	// HOMEBREW_VERBOSE
	// If set, always assume `--verbose` when running commands.
	Verbose bool `json:"HOMEBREW_VERBOSE" env:"HOMEBREW_VERBOSE"`
}

Environment represents Homebrew's environment configuration. Note that environment variables must have a value set to be detected. For example, run "export HOMEBREW_NO_INSECURE_REDIRECT=1" rather than just "export HOMEBREW_NO_INSECURE_REDIRECT".

`HOMEBREW_*` environment variables can also be set in Homebrew’s environment files:

  • /etc/homebrew/brew.env (system-wide)
  • $HOMEBREW_PREFIX/etc/homebrew/brew.env` (prefix-specific)
  • $XDG_CONFIG_HOME/homebrew/brew.env if $XDG_CONFIG_HOME is set or $HOME/.homebrew/brew.env otherwise (user-specific)

User-specific environment files take precedence over prefix-specific files and prefix-specific files take precedence over system-wide files (unless `HOMEBREW_SYSTEM_ENV_TAKES_PRIORITY` is set, see below).

Note that these files do not support shell variable expansion e.g. `$HOME` or command execution e.g. `$(cat file)`.

func Load

func Load() (*Environment, error)

Load loads the environment config from the OS environment.

func (*Environment) AddGitHubPackagesAuthHeader

func (e *Environment) AddGitHubPackagesAuthHeader(req http.Request)

AddGitHubPackagesAuthHeader adds the GitHub Packages auth header to the request.

func (*Environment) GitHubPackagesAuth

func (e *Environment) GitHubPackagesAuth() string

GitHubPackagesAuth derives the GitHub Packages auth from the env config.

From: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/brew.sh

func (*Environment) String

func (e *Environment) String() string

Jump to

Keyboard shortcuts

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