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

add netrc support to go_download_sdk #3718

Merged
merged 2 commits into from
Oct 6, 2023
Merged
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
7 changes: 6 additions & 1 deletion go/private/sdk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
load("//go/private:common.bzl", "executable_path")
load("//go/private:nogo.bzl", "go_register_nogo")
load("//go/private/skylib/lib:versions.bzl", "versions")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "read_user_netrc", "use_netrc")

MIN_SUPPORTED_VERSION = (1, 14, 0)

Expand Down Expand Up @@ -423,6 +423,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):

ctx.report_progress("Downloading and extracting Go toolchain")

auth = use_netrc(read_user_netrc(ctx), ctx.attr.urls, {})

# TODO(#2771): After bazelbuild/bazel#18448 is merged and available in
# the minimum supported version of Bazel, remove the workarounds below.
#
Expand All @@ -446,6 +448,7 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):
url = urls,
sha256 = sha256,
output = "go_sdk.tar.gz",
auth = auth,
)
res = ctx.execute(["tar", "-xf", "go_sdk.tar.gz", "--strip-components=1"])
if res.return_code:
Expand All @@ -464,12 +467,14 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256):
"go/test/fixedbugs/issue27836.dir/\336foo.go": "go/test/fixedbugs/issue27836.dir/thfoo.go",
"go/test/fixedbugs/issue27836.dir/\336main.go": "go/test/fixedbugs/issue27836.dir/thmain.go",
},
auth = auth,
)
else:
ctx.download_and_extract(
url = urls,
stripPrefix = strip_prefix,
sha256 = sha256,
auth = auth,
)

def _local_sdk(ctx, path):
Expand Down