Skip to content

Commit 029b9a1

Browse files
authored
Add tool target attribute to docker toolchain (#1946)
* Add tool target attribute to docker toolchain * Run buildifier and add docstrings * Add missing imports
1 parent f6ed806 commit 029b9a1

14 files changed

Lines changed: 99 additions & 19 deletions

File tree

container/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ bzl_library(
135135
bzl_library(
136136
name = "layer_tools",
137137
srcs = ["layer_tools.bzl"],
138-
deps = ["//skylib:path"],
138+
deps = [
139+
"//skylib:docker",
140+
"//skylib:path",
141+
],
139142
)
140143

141144
bzl_library(

container/layer_tools.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ load(
2222
"//skylib:path.bzl",
2323
_get_runfile_path = "runfile",
2424
)
25+
load(
26+
"//skylib:docker.bzl",
27+
"docker_path",
28+
)
2529

2630
def _extract_layers(ctx, name, artifact):
2731
config_file = ctx.actions.declare_file(name + "." + artifact.basename + ".config")
@@ -277,7 +281,7 @@ def incremental_load(
277281
template = ctx.file.incremental_load_template,
278282
substitutions = {
279283
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
280-
"%{docker_tool_path}": toolchain_info.tool_path,
284+
"%{docker_tool_path}": docker_path(toolchain_info),
281285
"%{load_statements}": "\n".join(load_statements),
282286
"%{run_statements}": "\n".join(run_statements),
283287
"%{run}": str(run),

contrib/automatic_container_release/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports_files(["run_checker.sh.tpl"])
2323
bzl_library(
2424
name = "configs_test",
2525
srcs = ["configs_test.bzl"],
26+
deps = ["//skylib:docker"],
2627
)
2728

2829
bzl_library(

contrib/automatic_container_release/configs_test.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ load(
2020
"//skylib:path.bzl",
2121
"runfile",
2222
)
23+
load(
24+
"//skylib:docker.bzl",
25+
"docker_path",
26+
)
2327

2428
def _get_runfile_path(ctx, f):
2529
return "${RUNFILES}/%s" % runfile(ctx, f)
@@ -70,7 +74,7 @@ def _impl(ctx):
7074
substitutions = {
7175
"%{cmd_args}": " ".join(cmd_args),
7276
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
73-
"%{docker_path}": toolchain_info.tool_path,
77+
"%{docker_path}": docker_path(toolchain_info),
7478
"%{image_name}": ctx.attr._checker + ":" + ctx.attr.checker_tag,
7579
"%{spec_container_paths}": " ".join(spec_container_paths),
7680
"%{specs}": " ".join(specs),

docker/package_managers/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ bzl_library(
3434
deps = [
3535
"//container",
3636
"//docker/util",
37+
"//skylib:docker",
3738
],
3839
)

docker/package_managers/download_pkgs.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ load(
1818
"//skylib:path.bzl",
1919
"runfile",
2020
)
21+
load(
22+
"//skylib:docker.bzl",
23+
"docker_path",
24+
)
2125

2226
def _generate_add_additional_repo_commands(ctx, additional_repos):
2327
return """printf "{repos}" >> /etc/apt/sources.list.d/{name}_repos.list""".format(
@@ -101,7 +105,7 @@ def _impl(ctx, image_tar = None, packages = None, additional_repos = None, outpu
101105
output = output_script,
102106
substitutions = {
103107
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
104-
"%{docker_tool_path}": toolchain_info.tool_path,
108+
"%{docker_tool_path}": docker_path(toolchain_info),
105109
"%{download_commands}": _generate_download_commands(ctx, packages, additional_repos),
106110
"%{image_id_extractor_path}": ctx.executable._extract_image_id.path,
107111
"%{image_tar}": image_tar.path,
@@ -127,7 +131,7 @@ def _impl(ctx, image_tar = None, packages = None, additional_repos = None, outpu
127131
output = output_executable,
128132
substitutions = {
129133
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
130-
"%{docker_tool_path}": toolchain_info.tool_path,
134+
"%{docker_tool_path}": docker_path(toolchain_info),
131135
"%{download_commands}": _generate_download_commands(ctx, packages, additional_repos),
132136
"%{image_id_extractor_path}": "${RUNFILES}/%s" % runfile(ctx, ctx.executable._extract_image_id),
133137
"%{image_tar}": image_tar.short_path,

docker/package_managers/install_pkgs.bzl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ users will write something like:
3939
4040
"""
4141

42+
load(
43+
"//skylib:docker.bzl",
44+
"docker_path",
45+
)
46+
4247
def _generate_install_commands(tar, installation_cleanup_commands):
4348
return """
4449
tar -xvf {tar}
@@ -94,7 +99,7 @@ def _impl(ctx, image_tar = None, installables_tar = None, installation_cleanup_c
9499
output = image_util,
95100
substitutions = {
96101
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
97-
"%{docker_tool_path}": toolchain_info.tool_path,
102+
"%{docker_tool_path}": docker_path(toolchain_info),
98103
},
99104
is_executable = True,
100105
)
@@ -106,7 +111,7 @@ def _impl(ctx, image_tar = None, installables_tar = None, installation_cleanup_c
106111
substitutions = {
107112
"%{base_image_tar}": image_tar.path,
108113
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
109-
"%{docker_tool_path}": toolchain_info.tool_path,
114+
"%{docker_tool_path}": docker_path(toolchain_info),
110115
"%{image_id_extractor_path}": ctx.executable._extract_image_id.path,
111116
"%{installables_tar}": installables_tar_path,
112117
"%{installer_script}": install_script.path,

docker/util/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ exports_files([
4040
bzl_library(
4141
name = "util",
4242
srcs = ["run.bzl"],
43+
deps = ["//skylib:docker"],
4344
)
4445

4546
# Re-package config_stripper as a library to be used in unit tests.

docker/util/run.bzl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ load(
2929
"//skylib:zip.bzl",
3030
_zip_tools = "tools",
3131
)
32+
load(
33+
"//skylib:docker.bzl",
34+
"docker_path",
35+
)
3236

3337
def _extract_impl(
3438
ctx,
@@ -79,7 +83,7 @@ def _extract_impl(
7983
"%{commands}": _process_commands(commands),
8084
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
8185
"%{docker_run_flags}": " ".join(docker_run_flags),
82-
"%{docker_tool_path}": toolchain_info.tool_path,
86+
"%{docker_tool_path}": docker_path(toolchain_info),
8387
"%{extract_file}": extract_file,
8488
"%{image_id_extractor_path}": ctx.executable._extract_image_id.path,
8589
"%{image_tar}": image.path,
@@ -196,7 +200,7 @@ def _commit_impl(
196200
output = image_utils,
197201
substitutions = {
198202
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
199-
"%{docker_tool_path}": toolchain_info.tool_path,
203+
"%{docker_tool_path}": docker_path(toolchain_info),
200204
},
201205
is_executable = True,
202206
)
@@ -209,7 +213,7 @@ def _commit_impl(
209213
"%{commands}": _process_commands(commands),
210214
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
211215
"%{docker_run_flags}": " ".join(docker_run_flags),
212-
"%{docker_tool_path}": toolchain_info.tool_path,
216+
"%{docker_tool_path}": docker_path(toolchain_info),
213217
"%{image_id_extractor_path}": ctx.executable._extract_image_id.path,
214218
"%{image_tar}": image.path,
215219
"%{output_image}": "bazel/%s:%s" % (
@@ -344,7 +348,7 @@ def _commit_layer_impl(
344348
output = image_utils,
345349
substitutions = {
346350
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
347-
"%{docker_tool_path}": toolchain_info.tool_path,
351+
"%{docker_tool_path}": docker_path(toolchain_info),
348352
},
349353
is_executable = True,
350354
)
@@ -370,7 +374,7 @@ def _commit_layer_impl(
370374
"%{commands}": _process_commands(commands),
371375
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
372376
"%{docker_run_flags}": " ".join(docker_run_flags),
373-
"%{docker_tool_path}": toolchain_info.tool_path,
377+
"%{docker_tool_path}": docker_path(toolchain_info),
374378
"%{env_file_path}": env_file.path,
375379
"%{image_id_extractor_path}": ctx.executable._extract_image_id.path,
376380
"%{image_last_layer_extractor_path}": ctx.executable._last_layer_extractor_tool.path,

skylib/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ package(default_visibility = ["//visibility:public"])
1818

1919
licenses(["notice"]) # Apache 2.0
2020

21+
bzl_library(
22+
name = "docker",
23+
srcs = ["docker.bzl"],
24+
)
25+
2126
bzl_library(
2227
name = "filetype",
2328
srcs = ["filetype.bzl"],

0 commit comments

Comments
 (0)