From cf925413abfaf99c95203381d4e33b7d430c7d13 Mon Sep 17 00:00:00 2001 From: Clayton Walker Date: Wed, 21 Aug 2024 14:48:56 -0600 Subject: [PATCH] Add bazel platform support --- bazel/container_structure_test.bzl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bazel/container_structure_test.bzl b/bazel/container_structure_test.bzl index 9a01e233..e59d183d 100644 --- a/bazel/container_structure_test.bzl +++ b/bazel/container_structure_test.bzl @@ -15,6 +15,10 @@ _attrs = { values = ["docker", "tar", "host"], doc = "See https://github.com/GoogleContainerTools/container-structure-test#running-file-tests-without-docker", ), + "platform": attr.string( + default = "linux/amd64", + doc = "Set platform if host is multi-platform capable (default \"linux/amd64\")", + ), "_runfiles": attr.label(default = "@bazel_tools//tools/bash/runfiles"), "_windows_constraint": attr.label(default = "@platforms//os:windows"), } @@ -58,6 +62,9 @@ def _structure_test_impl(ctx): for arg in ctx.files.configs: fixed_args.extend(["--config", "$(rlocation %s)" % to_rlocation_path(ctx, arg)]) + if ctx.attr.platform: + fixed_args.extend(["--platform", ctx.attr.platform]) + bash_launcher = ctx.actions.declare_file("%s.sh" % ctx.label.name) ctx.actions.write( bash_launcher,