Skip to content

Commit

Permalink
Make get_default_canonical_id public
Browse files Browse the repository at this point in the history
  • Loading branch information
Silic0nS0ldier committed Jun 14, 2024
1 parent 786a893 commit 0a537a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,16 @@ private StructImpl completeDownload(PendingDownload pendingDownload)
"Downloads a file to the output path for the provided url and returns a struct"
+ " containing <code>success</code>, a flag which is <code>true</code> if the"
+ " download completed successfully, and if successful, a hash of the file"
+ " with the fields <code>sha256</code> and <code>integrity</code>.",
+ " with the fields <code>sha256</code> and <code>integrity</code>."
+ "Setting an explicit <code>canonical_id</code> is highly recommended. e.g."
+ "<pre class='language-python'>\n"
+ "load(\"@bazel_tools//tools/build_defs/repo:cache.bzl\", \"get_default_canonical_id\")\n"
+ "# ...\n"
+ " repository_ctx.download(\n"
+ " url = urls,\n"
+ " canonical_id = get_default_canonical_id(repository_ctx, urls),\n"
+ " ),\n"
+ "</pre>",
useStarlarkThread = true,
parameters = {
@Param(
Expand Down Expand Up @@ -755,7 +764,16 @@ public Object download(
"Downloads a file to the output path for the provided url, extracts it, and returns a"
+ " struct containing <code>success</code>, a flag which is <code>true</code> if the"
+ " download completed successfully, and if successful, a hash of the file with the"
+ " fields <code>sha256</code> and <code>integrity</code>.",
+ " fields <code>sha256</code> and <code>integrity</code>."
+ "Setting an explicit <code>canonical_id</code> is highly recommended. e.g."
+ "<pre class='language-python'>\n"
+ "load(\"@bazel_tools//tools/build_defs/repo:cache.bzl\", \"get_default_canonical_id\")\n"
+ "# ...\n"
+ " repository_ctx.download_and_extract(\n"
+ " url = urls,\n"
+ " canonical_id = get_default_canonical_id(repository_ctx, urls),\n"
+ " ),\n"
+ "</pre>",
useStarlarkThread = true,
parameters = {
@Param(
Expand Down
2 changes: 1 addition & 1 deletion tools/build_defs/repo/cache.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

"""Returns the default canonical id to use for downloads."""

visibility("private")
visibility("public")

DEFAULT_CANONICAL_ID_ENV = "BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID"

Expand Down

0 comments on commit 0a537a9

Please sign in to comment.