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

[nuget-archive] Add index integrity attribute to nuget_archive #433

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
7 changes: 4 additions & 3 deletions dotnet/private/rules/nuget/nuget_archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def _process_key_and_file(groups, key, file):

return

def _get_package_urls(rctx, sources, auth, package_id, package_version):
def _get_package_urls(rctx, sources, auth, index_integrity, package_id, package_version):
base_addresses = {}
package_urls = []

Expand All @@ -274,7 +274,7 @@ def _get_package_urls(rctx, sources, auth, package_id, package_version):
# and the url schema for the package contents will be:
# {base_address}/{lower_id}/{lower_version}/{lower_id}.{lower_version}.nupkg
if source.endswith("index.json"):
rctx.download(source, auth = auth, output = "index.json")
rctx.download(source, auth = auth, output = "index.json", integrity = index_integrity)
index = json.decode(rctx.read("index.json"))
rctx.delete("index.json")
for resource in index["resources"]:
Expand Down Expand Up @@ -317,7 +317,7 @@ def _nuget_archive_impl(ctx):
# First get the auth dict for the package sources since the sources can be different than the
# package base url when using NuGet V3 feeds.
auth = _get_auth_dict(ctx, ctx.attr.netrc, ctx.attr.sources)
urls = _get_package_urls(ctx, ctx.attr.sources, auth, ctx.attr.id, ctx.attr.version)
urls = _get_package_urls(ctx, ctx.attr.sources, auth, ctx.attr.index_integrity, ctx.attr.id, ctx.attr.version)

# Then get the auth dict for the package base urls
auth = _get_auth_dict(ctx, ctx.attr.netrc, urls)
Expand Down Expand Up @@ -467,6 +467,7 @@ nuget_archive = repository_rule(
"id": attr.string(),
"version": attr.string(),
"sha512": attr.string(),
"index_integrity": attr.string(),
},
)

Expand Down