Documentation ¶
Overview ¶
Package core contains the core Bazelisk logic, as well as abstractions for Bazel repositories.
Index ¶
- Constants
- Variables
- func BuildURLFromFormat(config config.Config, formatURL, version string) (string, error)
- func MakeDefaultConfig() config.Config
- func RunBazelisk(args []string, repos *Repositories) (int, error)
- func RunBazeliskWithArgsFunc(argsFunc ArgsFunc, repos *Repositories) (int, error)
- func RunBazeliskWithArgsFuncAndConfig(argsFunc ArgsFunc, repos *Repositories, config config.Config) (int, error)
- type ArgsFunc
- type CandidateRepo
- type Commit
- type CommitRepo
- type CompareResponse
- type DownloadFunc
- type ForkRepo
- type ParentCommit
- type ReleaseFilter
- type ReleaseRepo
- type Repositories
- func (r *Repositories) DownloadFromBaseURL(baseURL, version, destDir, destFile string, config config.Config) (string, error)
- func (r *Repositories) DownloadFromFormatURL(config config.Config, formatURL, version, destDir, destFile string) (string, error)
- func (r *Repositories) ResolveVersion(bazeliskHome, fork, version string, config config.Config) (string, DownloadFunc, error)
- type RollingRepo
Constants ¶
const ( // BaseURLEnv is the name of the environment variable that stores the base URL for downloads. BaseURLEnv = "BAZELISK_BASE_URL" // FormatURLEnv is the name of the environment variable that stores the format string to generate URLs for downloads. FormatURLEnv = "BAZELISK_FORMAT_URL" )
Variables ¶
var (
// BazeliskVersion is filled in via x_defs when building a release.
BazeliskVersion = "development"
)
Functions ¶
func BuildURLFromFormat ¶ added in v1.17.0
func MakeDefaultConfig ¶ added in v1.18.0
func RunBazelisk ¶
func RunBazelisk(args []string, repos *Repositories) (int, error)
RunBazelisk runs the main Bazelisk logic for the given arguments and Bazel repositories.
func RunBazeliskWithArgsFunc ¶ added in v1.14.0
func RunBazeliskWithArgsFunc(argsFunc ArgsFunc, repos *Repositories) (int, error)
RunBazeliskWithArgsFunc runs the main Bazelisk logic for the given ArgsFunc and Bazel repositories.
func RunBazeliskWithArgsFuncAndConfig ¶ added in v1.18.0
func RunBazeliskWithArgsFuncAndConfig(argsFunc ArgsFunc, repos *Repositories, config config.Config) (int, error)
RunBazeliskWithArgsFuncAndConfig runs the main Bazelisk logic for the given ArgsFunc and Bazel repositories and config.
Types ¶
type ArgsFunc ¶ added in v1.14.0
ArgsFunc is a function that receives a resolved Bazel version and returns the arguments to invoke Bazel with.
type CandidateRepo ¶
type CandidateRepo interface { // GetCandidateVersions returns the versions of all available release candidates. GetCandidateVersions(bazeliskHome string) ([]string, error) // DownloadCandidate downloads the given Bazel release candidate into the specified location and returns the absolute path. DownloadCandidate(version, destDir, destFile string, config config.Config) (string, error) }
CandidateRepo represents a repository that stores Bazel release candidates.
type Commit ¶ added in v1.17.0
type Commit struct { SHA string `json:"sha"` PARENTS []ParentCommit `json:"parents"` }
type CommitRepo ¶
type CommitRepo interface { // GetLastGreenCommit returns the most recent commit at which a Bazel binary passed a specific Bazel CI pipeline. // If downstreamGreen is true, the pipeline is https://buildkite.com/bazel/bazel-at-head-plus-downstream, otherwise // it's https://buildkite.com/bazel/bazel-bazel GetLastGreenCommit(bazeliskHome string, downstreamGreen bool) (string, error) // DownloadAtCommit downloads a Bazel binary built at the given commit into the specified location and returns the absolute path. DownloadAtCommit(commit, destDir, destFile string, config config.Config) (string, error) }
CommitRepo represents a repository that stores Bazel binaries built at specific commits. It can also return the hashes of the most recent commits that passed Bazel CI pipelines successfully.
type CompareResponse ¶ added in v1.17.0
type DownloadFunc ¶
DownloadFunc downloads a specific Bazel binary to the given location and returns the absolute path.
type ForkRepo ¶
type ForkRepo interface { // GetVersions returns the versions of all available Bazel binaries in the given fork. GetVersions(bazeliskHome, fork string) ([]string, error) // DownloadVersion downloads the given Bazel binary from the specified fork into the given location and returns the absolute path. DownloadVersion(fork, version, destDir, destFile string, config config.Config) (string, error) }
ForkRepo represents a repository that stores a fork of Bazel (releases).
type ParentCommit ¶ added in v1.17.0
type ParentCommit struct {
SHA string `json:"sha"`
}
type ReleaseFilter ¶ added in v1.13.2
ReleaseFilter filters Bazel versions based on specific criteria.
type ReleaseRepo ¶
type ReleaseRepo interface { // GetReleaseVersions returns a list of all available release versions that match the given filter function. // Warning: the filter only works reliably if the versions are processed in descending order! GetReleaseVersions(bazeliskHome string, filter ReleaseFilter) ([]string, error) // DownloadRelease downloads the given Bazel version into the specified location and returns the absolute path. DownloadRelease(version, destDir, destFile string, config config.Config) (string, error) }
ReleaseRepo represents a repository that stores LTS Bazel releases.
type Repositories ¶
type Repositories struct { Releases ReleaseRepo Candidates CandidateRepo Fork ForkRepo Commits CommitRepo Rolling RollingRepo // contains filtered or unexported fields }
Repositories offers access to different types of Bazel repositories, mainly for finding and downloading the correct version of Bazel.
func CreateRepositories ¶
func CreateRepositories(releases ReleaseRepo, candidates CandidateRepo, fork ForkRepo, commits CommitRepo, rolling RollingRepo, supportsBaseURL bool) *Repositories
CreateRepositories creates a new Repositories instance with the given repositories. Any nil repository will be replaced by a dummy repository that raises an error whenever a download is attempted.
func (*Repositories) DownloadFromBaseURL ¶
func (r *Repositories) DownloadFromBaseURL(baseURL, version, destDir, destFile string, config config.Config) (string, error)
DownloadFromBaseURL can download Bazel binaries from a specific URL while ignoring the predefined repositories.
func (*Repositories) DownloadFromFormatURL ¶ added in v1.17.0
func (r *Repositories) DownloadFromFormatURL(config config.Config, formatURL, version, destDir, destFile string) (string, error)
DownloadFromFormatURL can download Bazel binaries from a specific URL while ignoring the predefined repositories.
func (*Repositories) ResolveVersion ¶
func (r *Repositories) ResolveVersion(bazeliskHome, fork, version string, config config.Config) (string, DownloadFunc, error)
ResolveVersion resolves a potentially relative Bazel version string such as "latest" to an absolute version identifier, and returns this identifier alongside a function to download said version.
type RollingRepo ¶ added in v1.8.0
type RollingRepo interface { // GetRollingVersions returns a list of all available rolling release versions. GetRollingVersions(bazeliskHome string) ([]string, error) // DownloadRolling downloads the given Bazel version into the specified location and returns the absolute path. DownloadRolling(version, destDir, destFile string, config config.Config) (string, error) }
RollingRepo represents a repository that stores rolling Bazel releases.