Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: safely set user agent #550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ var (
// BazeliskVersion is filled in via x_defs when building a release.
BazeliskVersion = "development"

fileConfig map[string]string
fileConfigOnce sync.Once
userAgentOnce sync.Once
)

// ArgsFunc is a function that receives a resolved Bazel version and returns the arguments to invoke
Expand Down Expand Up @@ -89,7 +88,10 @@ func RunBazeliskWithArgsFunc(argsFunc ArgsFunc, repos *Repositories) (int, error
// RunBazeliskWithArgsFuncAndConfig runs the main Bazelisk logic for the given ArgsFunc and Bazel
// repositories and config.
func RunBazeliskWithArgsFuncAndConfig(argsFunc ArgsFunc, repos *Repositories, config config.Config) (int, error) {
httputil.UserAgent = getUserAgent(config)

userAgentOnce.Do(func() {
httputil.UserAgent = getUserAgent(config)
})

bazeliskHome := config.Get("BAZELISK_HOME")
if len(bazeliskHome) == 0 {
Expand Down