Skip to content

Commit

Permalink
REFACTOR: introduce parameter - config
Browse files Browse the repository at this point in the history
  • Loading branch information
sf-jbazuzi committed Jan 17, 2024
1 parent 85cdf1d commit bed91ec
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func downloadBazel(bazelVersionString string, bazeliskHome string, repos *Reposi
// downloads/metadata/[fork-or-url]/bazel-[version-os-etc] is a text file containing a hex sha256 of the contents of the downloaded bazel file.
// downloads/sha256/[sha256]/bin/bazel[extension] contains the bazel with a particular sha256.
func downloadBazelIfNecessary(version string, bazeliskHome string, bazelForkOrURLDirName string, repos *Repositories, config config.Config, downloader DownloadFunc) (string, error) {
pathSegment, err := platforms.DetermineBazelFilename(version, false)
pathSegment, err := platforms.DetermineBazelFilename(version, false, config)
if err != nil {
return "", fmt.Errorf("could not determine path segment to use for Bazel binary: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion core/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (r *Repositories) DownloadFromBaseURL(baseURL, version, destDir, destFile s
return "", fmt.Errorf("%s is not set", BaseURLEnv)
}

srcFile, err := platforms.DetermineBazelFilename(version, true)
srcFile, err := platforms.DetermineBazelFilename(version, true, config)
if err != nil {
return "", err
}
Expand Down
1 change: 1 addition & 0 deletions platforms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
importpath = "github.com/bazelbuild/bazelisk/platforms",
visibility = ["//visibility:public"],
deps = [
"//config:go_default_library",
"//versions:go_default_library",
"@com_github_hashicorp_go_version//:go_default_library",
],
Expand Down
3 changes: 2 additions & 1 deletion platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"runtime"

"github.com/bazelbuild/bazelisk/config"
"github.com/bazelbuild/bazelisk/versions"
semver "github.com/hashicorp/go-version"
)
Expand Down Expand Up @@ -82,7 +83,7 @@ func DetermineOperatingSystem() (string, error) {
}

// DetermineBazelFilename returns the correct file name of a local Bazel binary.
func DetermineBazelFilename(version string, includeSuffix bool) (string, error) {
func DetermineBazelFilename(version string, includeSuffix bool, config_ config.Config) (string, error) {
flavor := "bazel"

osName, err := DetermineOperatingSystem()
Expand Down
6 changes: 3 additions & 3 deletions repositories/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type GcsListResponse struct {

// DownloadRelease downloads the given Bazel release into the specified location and returns the absolute path.
func (gcs *GCSRepo) DownloadRelease(version, destDir, destFile string, config config.Config) (string, error) {
srcFile, err := platforms.DetermineBazelFilename(version, true)
srcFile, err := platforms.DetermineBazelFilename(version, true, config)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func (gcs *GCSRepo) DownloadCandidate(version, destDir, destFile string, config
return "", fmt.Errorf("'%s' does not refer to a release candidate", version)
}

srcFile, err := platforms.DetermineBazelFilename(version, true)
srcFile, err := platforms.DetermineBazelFilename(version, true, config)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -299,7 +299,7 @@ func (gcs *GCSRepo) GetRollingVersions(bazeliskHome string) ([]string, error) {

// DownloadRolling downloads the given Bazel version into the specified location and returns the absolute path.
func (gcs *GCSRepo) DownloadRolling(version, destDir, destFile string, config config.Config) (string, error) {
srcFile, err := platforms.DetermineBazelFilename(version, true)
srcFile, err := platforms.DetermineBazelFilename(version, true, config)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion repositories/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type gitHubRelease struct {

// DownloadVersion downloads a Bazel binary for the given version and fork to the specified location and returns the absolute path.
func (gh *GitHubRepo) DownloadVersion(fork, version, destDir, destFile string, config config.Config) (string, error) {
filename, err := platforms.DetermineBazelFilename(version, true)
filename, err := platforms.DetermineBazelFilename(version, true, config)
if err != nil {
return "", err
}
Expand Down

0 comments on commit bed91ec

Please sign in to comment.