From f1394d83edc6632463f793d5ab17d3613968af21 Mon Sep 17 00:00:00 2001 From: thesayyn Date: Sat, 25 Feb 2023 02:44:20 +0300 Subject: [PATCH] fix: handle __main__ and no package gracefully --- oci/private/structure_test.bzl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/oci/private/structure_test.bzl b/oci/private/structure_test.bzl index 85195a48..c1736910 100644 --- a/oci/private/structure_test.bzl +++ b/oci/private/structure_test.bzl @@ -24,9 +24,12 @@ exec "{st_path}" test {fixed_args} "$@" def _structure_test_impl(ctx): st_info = ctx.toolchains["@contrib_rules_oci//oci:st_toolchain_type"].st_info - default_image_tag = "{workspace}.local/{package}/{name}:latest".format( - workspace = ctx.workspace_name, - package = ctx.label.package.replace("/", "_"), + workspace = "default_workspace" if ctx.workspace_name == "__main__" else ctx.workspace_name + package = "{}/".format(ctx.label.package.replace("/", "_")) if ctx.label.package else "" + + default_image_tag = "{workspace}.local/{optional_package}{name}:latest".format( + workspace = workspace, + optional_package = package, name = ctx.label.name, )