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

Fix cross repo multifile apko configs #80

Merged
merged 1 commit into from
Jun 19, 2024
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
14 changes: 14 additions & 0 deletions apko/private/apko_image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ def _impl(ctx):

args.add("--vcs=false")

# This is a solution for building apko images with base image that's configs are declared in remote repositories.
# 1. short paths in Bazel depend on the caller context. For example. There are
# - //foo:bar and //foo:baz targets in repo A,
# - //foo:bar depends on //foo:baz.
# - When calling bazel build //foo:bar within A, the shortpath of //foo:baz is foo/baz.
# - But if one calls bazel build @A//foo:bar from repo B, the short path of foo:baz is ../A/foo/baz
# 2. On the other hand apko dumps the checksum of config file into lockfile, so we cannot generate config files that would very depending on
# where they are called from.
# 3. This is a problem only when foo/bar is called both from A and from B - we need to choose one of the short paths in the config. The other possibility
# is added with include-paths flag.
supports_include_paths = versions.is_at_least("0.15.0", apko_info.version)
if supports_include_paths:
args.add("--include-paths=../{}".format(ctx.label.workspace_name))

args.add_all(ctx.attr.args)

lockfile = ctx.attr.contents[OutputGroupInfo].lockfile.to_list()[0]
Expand Down
Loading