@@ -18,6 +18,7 @@ This module defines docker toolchain rules
1818DockerToolchainInfo = provider (
1919 doc = "Docker toolchain rule parameters" ,
2020 fields = {
21+ "build_tar_target" : "Optional Bazel target for the build_tar tool" ,
2122 "client_config" : "A custom directory for the docker client " +
2223 "config.json. If DOCKER_CONFIG is not specified, " +
2324 "the value of the DOCKER_CONFIG environment variable " +
@@ -41,6 +42,7 @@ DockerToolchainInfo = provider(
4142def _docker_toolchain_impl (ctx ):
4243 toolchain_info = platform_common .ToolchainInfo (
4344 info = DockerToolchainInfo (
45+ build_tar_target = ctx .attr .build_tar_target ,
4446 docker_flags = ctx .attr .docker_flags ,
4547 client_config = ctx .attr .client_config ,
4648 gzip_path = ctx .attr .gzip_path ,
@@ -58,6 +60,12 @@ def _docker_toolchain_impl(ctx):
5860docker_toolchain = rule (
5961 implementation = _docker_toolchain_impl ,
6062 attrs = {
63+ "build_tar_target" : attr .label (
64+ allow_files = True ,
65+ doc = "Bazel target for the build_tar tool." ,
66+ cfg = "host" ,
67+ executable = True ,
68+ ),
6169 "client_config" : attr .string (
6270 default = "" ,
6371 doc = "A custom directory for the docker client config.json. If " +
@@ -136,13 +144,18 @@ def _toolchain_configure_impl(repository_ctx):
136144 docker_flags = []
137145 docker_flags += repository_ctx .attr .docker_flags
138146
147+ build_tar_attr = ""
148+ if repository_ctx .attr .build_tar_target :
149+ build_tar_attr = "build_tar_target = \" %s\" ," % repository_ctx .attr .build_tar_target
150+
139151 # If client_config is not set we need to pass an empty string to the
140152 # template.
141153 client_config = repository_ctx .attr .client_config or ""
142154 repository_ctx .template (
143155 "BUILD" ,
144156 Label ("@io_bazel_rules_docker//toolchains/docker:BUILD.tpl" ),
145157 {
158+ "%{BUILD_TAR_ATTR}" : "%s" % build_tar_attr ,
146159 "%{DOCKER_CONFIG}" : "%s" % client_config ,
147160 "%{DOCKER_FLAGS}" : "%s" % "\" , \" " .join (docker_flags ),
148161 "%{TOOL_ATTR}" : "%s" % tool_attr ,
@@ -167,6 +180,13 @@ def _toolchain_configure_impl(repository_ctx):
167180# Repository rule to generate a docker_toolchain target
168181toolchain_configure = repository_rule (
169182 attrs = {
183+ "build_tar_target" : attr .label (
184+ executable = True ,
185+ cfg = "host" ,
186+ allow_files = True ,
187+ mandatory = False ,
188+ doc = "The bazel target for the build_tar tool." ,
189+ ),
170190 "client_config" : attr .string (
171191 mandatory = False ,
172192 doc = "A custom directory for the docker client " +
0 commit comments