Documentation
¶
Index ¶
- type BinaryConfig
- type BottleConfig
- type BuildConfig
- type Config
- func (c *Config) ApplyGitDefaults()
- func (c *Config) BinaryNames() []string
- func (c *Config) GitURL() string
- func (c *Config) RootURL() string
- func (c *Config) SetDefaults()
- func (c *Config) SourceURL() string
- func (c *Config) TapGitHubURL() string
- func (c *Config) Validate() error
- func (c *Config) ValidateFor(needToken bool) error
- type FormulaBuildConfig
- type FormulaConfig
- type InstallConfig
- type MultiError
- type RegistryConfig
- type SourceConfig
- type TapConfig
- type TestConfig
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryConfig ¶
type BinaryConfig struct {
Name string `mapstructure:"name"`
InstallPath string `mapstructure:"install_path"`
}
BinaryConfig defines a binary to include in bottles. A bare string in YAML is accepted as shorthand for {name: ...}.
type BottleConfig ¶
type BottleConfig struct {
// Cellar setting for bottles
Cellar string `mapstructure:"cellar"`
// Platforms to generate bottles for (empty = auto-discover all)
Platforms []string `mapstructure:"platforms"`
// Platforms to exclude from generation
ExcludePlatforms []string `mapstructure:"exclude_platforms"`
// Rebuild number (0 for initial release)
Rebuild int `mapstructure:"rebuild"`
// Force refresh platform cache
RefreshPlatforms bool `mapstructure:"refresh_platforms"`
}
BottleConfig defines bottle generation settings
type BuildConfig ¶
type BuildConfig struct {
// Packages to build (e.g., ["./cmd/myapp"])
Packages []string `mapstructure:"packages"`
// Ldflags template (supports {{.Version}}, {{.Commit}}, {{.ShortCommit}},
// {{.Date}}, {{.Tag}})
Ldflags string `mapstructure:"ldflags"`
// Build tags (go build -tags), also applied to the source-built formula
Tags []string `mapstructure:"tags"`
// Extra environment variables for go build, as KEY=value strings.
// (A YAML map would lose case: viper lowercases map keys.)
Env []string `mapstructure:"env"`
// Enable CGO (default: false for portable static binaries)
CGOEnabled bool `mapstructure:"cgo_enabled"`
// Use -trimpath for reproducible builds (default: true).
// Pointer so `trimpath: false` is distinguishable from unset.
Trimpath *bool `mapstructure:"trimpath"`
// Extra go build flags
Flags []string `mapstructure:"flags"`
// Path to go.mod directory (default: ".")
ModDir string `mapstructure:"mod_dir"`
// Number of parallel builds (default: GOMAXPROCS)
Parallel int `mapstructure:"parallel"`
}
BuildConfig defines Go build configuration for ko-like mode
func (*BuildConfig) TrimpathEnabled ¶ added in v0.8.0
func (b *BuildConfig) TrimpathEnabled() bool
TrimpathEnabled reports whether cross-compiled bottles are built with -trimpath (default: true, matching what std_go_args does for the source-built formula).
type Config ¶
type Config struct {
// Formula content (gobottle owns the generated formula outright)
Formula FormulaConfig `mapstructure:"formula"`
// Version being bottled (no "v" prefix; normalized in SetDefaults)
Version string `mapstructure:"version"`
// Source configuration
Source SourceConfig `mapstructure:"source"`
// Bottle configuration
Bottle BottleConfig `mapstructure:"bottle"`
// Registry configuration
Registry RegistryConfig `mapstructure:"registry"`
// Tap configuration
Tap TapConfig `mapstructure:"tap"`
// Binary configuration (multi-binary support)
Binaries []BinaryConfig `mapstructure:"binaries"`
}
Config represents the complete gobottle configuration. Precedence (highest first): CLI flag > GOBOTTLE_* env > config file > git-derived defaults > built-in defaults.
func Load ¶
Load unmarshals the full configuration from the given viper instance. Because command flags and GOBOTTLE_* env vars are bound into viper, this single call realizes the whole precedence chain: flag > env > config file > flag default.
func (*Config) ApplyGitDefaults ¶
func (c *Config) ApplyGitDefaults()
ApplyGitDefaults attempts to infer configuration values from git context. Uses go-git library instead of exec'ing git binary.
func (*Config) BinaryNames ¶
BinaryNames returns just the names of all configured binaries
func (*Config) GitURL ¶
GitURL returns the git clone URL for the source repository (for head stanzas).
func (*Config) RootURL ¶
RootURL returns the bottle block root_url. Brew appends "/<formula>" to this when constructing manifest and blob URLs, so the formula name must NOT be part of it.
func (*Config) SetDefaults ¶
func (c *Config) SetDefaults()
SetDefaults sets default values for the configuration
func (*Config) SourceURL ¶
SourceURL returns the source tarball URL for the formula. Returns explicit URL if set, otherwise derives from GitHub owner/repo/version. Returns empty string when derivation is not possible.
func (*Config) TapGitHubURL ¶
TapGitHubURL returns the GitHub URL for the tap repository
func (*Config) ValidateFor ¶
ValidateFor validates the config for a pipeline stage. needToken=false skips the registry-token requirement (local build stage).
type FormulaBuildConfig ¶ added in v0.8.0
type FormulaBuildConfig struct {
// Enabled renders the source-build install block (default: true).
// `enabled: false` restores the legacy `bin.install` block, which only
// works when pouring a bottle.
Enabled *bool `mapstructure:"enabled"`
// Go is the depends_on spec for the build-time Go toolchain
// (default: "go"; e.g. "go@1.23" to pin)
Go string `mapstructure:"go"`
// Packages to compile (default: source.build.packages, else ["."])
Packages []string `mapstructure:"packages"`
// Ldflags template, rendered with Ruby interpolations
// (default: source.build.ldflags)
Ldflags string `mapstructure:"ldflags"`
// Tags become std_go_args(tags: [...])
Tags []string `mapstructure:"tags"`
// Flags are extra `go build` flags (default: source.build.flags)
Flags []string `mapstructure:"flags"`
// Env sets ENV["KEY"] = "value" lines (default: source.build.env);
// CGO_ENABLED is always derived from source.build.cgo_enabled so the
// source build matches the bottle
Env []string `mapstructure:"env"`
// ModDir is the go.mod directory, wrapped in `cd "<dir>" do`
// (default: source.build.mod_dir)
ModDir string `mapstructure:"mod_dir"`
}
FormulaBuildConfig describes how the *generated formula* compiles from source on the user's machine. Distinct from source.build, which is how gobottle cross-compiles bottles on the release machine; the two share a recipe, so every field here defaults from source.build (see SetDefaults) and existing configurations need no edits.
func (*FormulaBuildConfig) IsEnabled ¶ added in v0.8.0
func (f *FormulaBuildConfig) IsEnabled() bool
IsEnabled reports whether the generated formula gets a source-build install block (default: true).
type FormulaConfig ¶
type FormulaConfig struct {
// Name of the formula (default: repo name)
Name string `mapstructure:"name"`
// Description for the desc stanza (brew audit requires one; warned if empty)
Description string `mapstructure:"description"`
// Homepage URL (default: https://github.com/<owner>/<repo>)
Homepage string `mapstructure:"homepage"`
// License as an SPDX identifier; omitted from the formula if empty
License string `mapstructure:"license"`
// Head emits a `head "<repo>.git", branch: "<branch>"` stanza.
// Tri-state: unset defaults to true whenever a git URL is derivable (the
// generated install block compiles from source, so --HEAD works), while an
// explicit `head: false` suppresses the stanza. Resolved in SetDefaults.
Head *bool `mapstructure:"head"`
// HeadBranch overrides the head branch (default: "main")
HeadBranch string `mapstructure:"head_branch"`
// Build controls how the generated formula compiles from source under
// `brew install --build-from-source` and `--HEAD`
Build FormulaBuildConfig `mapstructure:"build"`
// Dependencies become depends_on lines
Dependencies []string `mapstructure:"dependencies"`
// Conflicts become conflicts_with lines
Conflicts []string `mapstructure:"conflicts"`
// Caveats is emitted verbatim in a caveats heredoc
Caveats string `mapstructure:"caveats"`
// Install customizes the install block beyond bin.install
Install InstallConfig `mapstructure:"install"`
// Test customizes the test block
Test TestConfig `mapstructure:"test"`
// Service is a verbatim `service do` block body
Service string `mapstructure:"service"`
// Template is a path to a Go template overriding the built-in formula
// template; it receives the full formula model.
Template string `mapstructure:"template"`
}
FormulaConfig drives formula generation: every overrideable aspect of the rendered formula lives here. A bare string in YAML ("formula: mytool") is accepted as shorthand for {name: mytool}.
type InstallConfig ¶
type InstallConfig struct {
// Completions emits generate_completions_from_executable for each binary
Completions bool `mapstructure:"completions"`
// CompletionsCommand is the subcommand generating completion scripts,
// invoked as `<binary> <command...> <shell>` (default: ["completion"],
// the cobra convention)
CompletionsCommand []string `mapstructure:"completions_command"`
// Extra lines are appended verbatim to the install block
Extra []string `mapstructure:"extra"`
}
InstallConfig customizes the generated install block.
type MultiError ¶
type MultiError struct {
Errors []error
}
MultiError aggregates multiple errors
func (*MultiError) Error ¶
func (e *MultiError) Error() string
type RegistryConfig ¶
type RegistryConfig struct {
// GHCR configuration
Host string `mapstructure:"host"`
Owner string `mapstructure:"owner"`
// RootPath is the image path between host and formula name
// (default: "<owner>/<tap repo minus homebrew- prefix>", mirroring
// homebrew-core's ghcr.io/homebrew/core/<formula> layout). The formula's
// root_url becomes "https://<host>/v2/<root_path>"; brew appends the
// formula name itself. Env: GOBOTTLE_REPO or GOBOTTLE_REGISTRY_ROOT_PATH.
RootPath string `mapstructure:"root_path"`
// Authentication token
Token string `mapstructure:"token"`
}
RegistryConfig defines OCI registry settings
type SourceConfig ¶
type SourceConfig struct {
// Type: "github", "local", or "go"
Type string `mapstructure:"type"`
// GitHub source options
Owner string `mapstructure:"owner"`
Repo string `mapstructure:"repo"`
Tag string `mapstructure:"tag"`
// Local source options
DistPath string `mapstructure:"dist_path"`
// Go source options (ko-like mode)
Build BuildConfig `mapstructure:"build"`
// Source tarball options (for formula generation)
URL string `mapstructure:"url"` // Source tarball URL (auto-derived if empty)
SHA256 string `mapstructure:"sha256"` // Source tarball SHA256 (computed if empty)
}
SourceConfig defines where to fetch artifacts from
type TapConfig ¶
type TapConfig struct {
// Tap repository
Owner string `mapstructure:"owner"`
Repo string `mapstructure:"repo"`
Branch string `mapstructure:"branch"`
// Formula path within tap
FormulaPath string `mapstructure:"formula_path"`
// Commit message template
CommitMessage string `mapstructure:"commit_message"`
// Token for tap repository (defaults to registry token)
Token string `mapstructure:"token"`
}
TapConfig defines Homebrew tap repository settings
type TestConfig ¶
type TestConfig struct {
// Command arguments for `system bin/"<binary>", ...` (default: ["--version"])
Command []string `mapstructure:"command"`
// Raw replaces the whole test body verbatim
Raw string `mapstructure:"raw"`
}
TestConfig customizes the generated test block.
type ValidationError ¶
ValidationError represents a configuration validation error
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string