core

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 21 Imported by: 5

Documentation

Overview

Package core contains the core Bazelisk logic, as well as abstractions for Bazel repositories.

Index

Constants

View Source
const (
	// BaseURLEnv is the name of the environment variable that stores the base URL for downloads.
	BaseURLEnv = "BAZELISK_BASE_URL"
)

Variables

View Source
var (
	// BazeliskVersion is filled in via x_defs when building a release.
	BazeliskVersion = "development"
)

Functions

func GetEnvOrConfig

func GetEnvOrConfig(name string) string

GetEnvOrConfig reads a configuration value from the environment, but fall back to reading it from .bazeliskrc in the workspace root.

func RunBazelisk

func RunBazelisk(args []string, repos *Repositories) (int, error)

RunBazelisk runs the main Bazelisk logic for the given arguments and Bazel repositories.

func ScanIssuesForIncompatibleFlags

func ScanIssuesForIncompatibleFlags(issuesJSON []byte) (map[string]*FlagDetails, error)

ScanIssuesForIncompatibleFlags is visible for testing. TODO: move this function and its test into a dedicated package.

Types

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) (string, error)
}

CandidateRepo represents a repository that stores Bazel release candidates.

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) (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 DownloadFunc

type DownloadFunc func(destDir, destFile string) (string, error)

DownloadFunc downloads a specific Bazel binary to the given location and returns the absolute path.

type FlagDetails added in v1.7.2

type FlagDetails struct {
	Name          string
	ReleaseToFlip string
	IssueURL      string
}

FlagDetails represents an incompatible flag that should be flipped later. It's currently exported for testing purposes.

func (*FlagDetails) String added in v1.7.2

func (f *FlagDetails) String() string

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) (string, error)
}

ForkRepo represents a repository that stores a fork of Bazel (releases).

type ReleaseRepo

type ReleaseRepo interface {
	// GetReleaseVersions returns a list of all available release versions. If lastN is smaller than 1, all available versions are being returned.
	GetReleaseVersions(bazeliskHome string, lastN int) ([]string, error)

	// DownloadRelease downloads the given Bazel version into the specified location and returns the absolute path.
	DownloadRelease(version, destDir, destFile string) (string, error)
}

ReleaseRepo represents a repository that stores Bazel releases.

type Repositories

type Repositories struct {
	Releases   ReleaseRepo
	Candidates CandidateRepo
	Fork       ForkRepo
	Commits    CommitRepo
	// 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, 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) (string, error)

DownloadFromBaseURL can download Bazel binaries from a specific URL while ignoring the predefined repositories.

func (*Repositories) ResolveVersion

func (r *Repositories) ResolveVersion(bazeliskHome, fork, version string) (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.

Jump to

Keyboard shortcuts

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