Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[layer_tools/generate_args_for_image] Inject extra argument to the given callback #2088

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions container/layer_tools.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ def _file_path(ctx, val):
"""
return val.path

def generate_args_for_image(ctx, image, to_path = _file_path):
def generate_args_for_image(ctx, image, to_path = _file_path, **kwargs):
"""Generates arguments & inputs for the given image.

Args:
ctx: The context.
image: The image parts dictionary as returned by 'get_from_target'.
to_path: A function to transform the string paths as they
are added as arguments.
**kwargs: Arguments to give to the `to_path` function.

Returns:
The arguments to call the pusher, digester & flatenner with to load
Expand All @@ -77,7 +78,7 @@ def generate_args_for_image(ctx, image, to_path = _file_path):
uncompressed_layers = image.get("unzipped_layer", [])
digest_files = image.get("blobsum", [])
diff_id_files = image.get("diff_id", [])
args = ["--config={}".format(to_path(ctx, image["config"]))]
args = ["--config={}".format(to_path(ctx, image["config"], **kwargs))]
inputs = [image["config"]]
inputs += compressed_layers
inputs += uncompressed_layers
Expand All @@ -89,18 +90,18 @@ def generate_args_for_image(ctx, image, to_path = _file_path):
diff_id_file = diff_id_files[i]
args.append(
"--layer={},{},{},{}".format(
to_path(ctx, compressed_layer),
to_path(ctx, uncompressed_layer),
to_path(ctx, digest_file),
to_path(ctx, diff_id_file),
to_path(ctx, compressed_layer, **kwargs),
to_path(ctx, uncompressed_layer, **kwargs),
to_path(ctx, digest_file, **kwargs),
to_path(ctx, diff_id_file, **kwargs),
),
)
if image.get("legacy"):
inputs.append(image["legacy"])
args.append("--tarball={}".format(to_path(ctx, image["legacy"])))
args.append("--tarball={}".format(to_path(ctx, image["legacy"], **kwargs)))
if image["manifest"]:
inputs.append(image["manifest"])
args.append("--manifest={}".format(to_path(ctx, image["manifest"])))
args.append("--manifest={}".format(to_path(ctx, image["manifest"], **kwargs)))
return args, inputs

def get_from_target(ctx, name, attr_target, file_target = None):
Expand Down