Skip to content

Commit

Permalink
Fix cross repo multifile apko configs (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mhazy authored Jun 19, 2024
1 parent 4df2175 commit b097884
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit b097884

Please sign in to comment.