Skip to content

Commit 14fd546

Browse files
authored
Thread files from image's ancestors all the way through to it's output (#65)
* Pass the files of an images ancestors through to it's output * Better variable name for base's OCILayer
1 parent e48bbc7 commit 14fd546

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

oci/image.bzl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ oci_image_index = rule(
143143
def _oci_image_impl(ctx):
144144
toolchain = ctx.toolchains["@com_github_datadog_rules_oci//oci:toolchain"]
145145

146-
layout = ctx.attr.base[OCILayout]
147-
148146
base_desc = get_descriptor_file(ctx, ctx.attr.base[OCIDescriptor])
147+
base_layout = ctx.attr.base[OCILayout]
149148

150149
manifest_desc_file = ctx.actions.declare_file("{}.manifest.descriptor.json".format(ctx.label.name))
151150
manifest_file = ctx.actions.declare_file("{}.manifest.json".format(ctx.label.name))
@@ -177,7 +176,7 @@ def _oci_image_impl(ctx):
177176
ctx.actions.run(
178177
executable = toolchain.sdk.ocitool,
179178
arguments = [
180-
"--layout={}".format(layout.blob_index.path),
179+
"--layout={}".format(base_layout.blob_index.path),
181180
"append-layers",
182181
"--bazel-version-file={}".format(ctx.version_file.path),
183182
"--base={}".format(base_desc.path),
@@ -196,10 +195,14 @@ def _oci_image_impl(ctx):
196195
["--annotations={}={}".format(k, v) for k, v in annotations.items()] +
197196
["--labels={}={}".format(k, v) for k, v in labels.items()] +
198197
["--env={}".format(env) for env in ctx.attr.env],
199-
inputs = [ctx.version_file, base_desc, layout.blob_index, entrypoint_config_file] +
200-
ctx.files.layers +
198+
inputs = [
199+
ctx.version_file,
200+
base_desc,
201+
base_layout.blob_index,
202+
entrypoint_config_file,
203+
] + ctx.files.layers +
201204
layer_descriptor_files +
202-
layout.files.to_list(),
205+
base_layout.files.to_list(),
203206
outputs = [
204207
manifest_file,
205208
config_file,
@@ -214,7 +217,10 @@ def _oci_image_impl(ctx):
214217
),
215218
OCILayout(
216219
blob_index = layout_file,
217-
files = depset(ctx.files.layers + [manifest_file, config_file, layout_file]),
220+
files = depset(
221+
ctx.files.layers + [manifest_file, config_file, layout_file],
222+
transitive = [base_layout.files],
223+
),
218224
),
219225
DefaultInfo(
220226
files = depset([

0 commit comments

Comments
 (0)