From 9d29a6acfdd0f6d64bc53589c6822b5b7553b3db Mon Sep 17 00:00:00 2001 From: "Artem V. Navrotskiy" Date: Mon, 12 Sep 2022 23:21:17 +0300 Subject: [PATCH] Add tag to `PushInfo` provider --- container/providers.bzl | 1 + container/push.bzl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/container/providers.bzl b/container/providers.bzl index 4c04fbc95..0a08c8265 100644 --- a/container/providers.bzl +++ b/container/providers.bzl @@ -53,6 +53,7 @@ PushInfo = provider(fields = [ "registry", "repository", "digest", + "tag", ]) # A provider containing information exposed by filter_layer rules diff --git a/container/push.bzl b/container/push.bzl index baef9c25f..045e992a3 100644 --- a/container/push.bzl +++ b/container/push.bzl @@ -59,7 +59,11 @@ def _impl(ctx): # If a tag file is provided, override with tag value if ctx.file.tag_file: tag = "$(cat {})".format(_get_runfile_path(ctx, ctx.file.tag_file)) + tag_file = ctx.file.tag_file pusher_input.append(ctx.file.tag_file) + else: + tag_file = ctx.actions.declare_file(ctx.label.name + "_tag") + ctx.actions.write(tag_file, "latest") stamp = ctx.attr.stamp[StampSettingInfo].value stamp_inputs = [ctx.info_file, ctx.version_file] if stamp else [] @@ -137,6 +141,7 @@ def _impl(ctx): registry = registry, repository = repository, digest = ctx.outputs.digest, + tag = tag_file, ), ]