Skip to content

Commit

Permalink
[GoogleContainerTools#144]: Add rctx.watch and repo name fix in deb_r…
Browse files Browse the repository at this point in the history
…esolve
  • Loading branch information
dillon-giacoppo committed Dec 22, 2024
1 parent 81c2dfd commit c813cad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions apt/apt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def _apt_install(
"""
_deb_resolve(
name = name + "_resolve",
install_name = name,
manifest = manifest,
resolve_transitive = resolve_transitive,
)
Expand Down
1 change: 1 addition & 0 deletions apt/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _distroless_extension(module_ctx):

deb_resolve(
name = install.name + "_resolve",
install_name = install.name,
manifest = install.manifest,
resolve_transitive = install.resolve_transitive,
)
Expand Down
7 changes: 6 additions & 1 deletion apt/private/deb_resolve.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ load(":version_constraint.bzl", "version_constraint")
def _parse_manifest(rctx, yq_toolchain_prefix, manifest):
is_windows = repo_utils.is_windows(rctx)
host_yq = Label("@{}_{}//:yq{}".format(yq_toolchain_prefix, repo_utils.platform(rctx), ".exe" if is_windows else ""))

if hasattr(rctx, "watch"):
rctx.watch(manifest)

yq_args = [
str(rctx.path(host_yq)),
str(rctx.path(manifest)),
Expand Down Expand Up @@ -120,7 +124,7 @@ def _deb_resolve_impl(rctx):
# NOTE: the split("~") is needed when we run bazel from another
# directory, e.g. when running e2e tests we change dir to e2e/smoke
# and then rctx.name is 'rules_distroless~~apt~bullseye'
repo_name = rctx.name.split("~")[-1].replace("_resolve", ""),
repo_name = rctx.attr.install_name,
lock_label = lock_label,
workspace_relative_path = workspace_relative_path,
),
Expand All @@ -132,6 +136,7 @@ def _deb_resolve_impl(rctx):
deb_resolve = repository_rule(
implementation = _deb_resolve_impl,
attrs = {
"install_name": attr.string(),
"manifest": attr.label(),
"resolve_transitive": attr.bool(default = True),
"yq_toolchain_prefix": attr.string(default = "yq"),
Expand Down

0 comments on commit c813cad

Please sign in to comment.