Skip to content

Commit

Permalink
http_file: Support canonical_id attribute
Browse files Browse the repository at this point in the history
Fixes bazelbuild#10612.

Change-Id: I93d95c23c71616bc4ea8e5532c9c8ee82a1f8c7b
PiperOrigin-RevId: 290583310
  • Loading branch information
davido authored and copybara-github committed Jan 20, 2020
1 parent 24dafca commit 3e5ece3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tools/build_defs/repo/http.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def _http_file_impl(ctx):
"file/" + downloaded_file_path,
ctx.attr.sha256,
ctx.attr.executable,
canonical_id = ctx.attr.canonical_id,
auth = auth,
)
ctx.file("WORKSPACE", "workspace(name = \"{name}\")".format(name = ctx.name))
Expand Down Expand Up @@ -153,6 +154,7 @@ def _http_jar_impl(ctx):
all_urls,
"jar/downloaded.jar",
ctx.attr.sha256,
canonical_id = ctx.attr.canonical_id,
auth = auth,
)
ctx.file("WORKSPACE", "workspace(name = \"{name}\")".format(name = ctx.name))
Expand Down Expand Up @@ -193,8 +195,8 @@ easier but should be set before shipping.""",
"canonical_id": attr.string(
doc = """A canonical id of the archive downloaded.
If specified and non-empty, bazel will not take a the archive from cache,
unless is was added to the cache by a request with the same canonical id.
If specified and non-empty, bazel will not take the archive from cache,
unless it was added to the cache by a request with the same canonical id.
""",
),
"strip_prefix": attr.string(
Expand Down Expand Up @@ -358,6 +360,13 @@ This must match the SHA-256 of the file downloaded. _It is a security risk
to omit the SHA-256 as remote files can change._ At best omitting this
field will make your build non-hermetic. It is optional to make development
easier but should be set before shipping.""",
),
"canonical_id": attr.string(
doc = """A canonical id of the archive downloaded.
If specified and non-empty, bazel will not take the archive from cache,
unless it was added to the cache by a request with the same canonical id.
""",
),
"urls": attr.string_list(
mandatory = True,
Expand Down Expand Up @@ -401,6 +410,13 @@ _http_jar_attrs = {
"sha256": attr.string(
doc = "The expected SHA-256 of the file downloaded.",
),
"canonical_id": attr.string(
doc = """A canonical id of the archive downloaded.
If specified and non-empty, bazel will not take the archive from cache,
unless it was added to the cache by a request with the same canonical id.
""",
),
"url": attr.string(
doc =
"The URL to fetch the jar from. It must end in `.jar`.",
Expand Down

0 comments on commit 3e5ece3

Please sign in to comment.