Commit 078bdd8
authored
[layer_tools/generate_args_for_image] Inject extra argument to the given callback (#2088)
When using a transition we need to give a callback function
to compute a path specific for this transition.
This information is not available from the context (ctx)
and the given file.
We need to have a way to inject this extra information.
Example with an architecture specific transition:
```starlark
def _to_arch_path(ctx, f, arch = None):
"""Returns the architecture specific path of the given file f."""
return paths.join(
paths.dirname(f.short_path),
arch,
paths.basename(f.short_path),
)
def _xxx_impl(ctx):
...
# image is an attribute with a 1:2+ transition
for image_target in ctx.attr.image:
image = ... [ImageInfo].container_parts
arch = ...
...
img_args, img_inputs = generate_args_for_image(
ctx, image, _to_arch_path, arch = arch,
)
...
symlinks.update({
_to_arch_path(ctx, i, arch = arch): i
for i in img_inputs
})
...
runfiles = ctx.runfiles(
files = ...
symlinks = symlinks
)
```1 parent 5436ff9 commit 078bdd8
1 file changed
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | | - | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | | - | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
0 commit comments