-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
fix: forward well known attributes to macro expanded targets #370
Conversation
I feel like we shouldn't have to do this one by one. I'll check if there's a macro that could return |
#350 is an example |
Is the proposal to make a Is it typical / idiomatic / safe to just forward all unknown |
exactly, but I believe this should go into bazel-lib. https://github.com/aspect-build/bazel-lib/tree/main |
Thanks for the feedback. I took a pass at something which may be helpful here: bazel-contrib/bazel-lib#553. The changes here end up looking something like: @@ -21,7 +22,7 @@ oci_image_rule = _oci_image
oci_image_index = _oci_image_index
oci_push_rule = _oci_push
-def oci_image(name, labels = None, annotations = None, env = None, cmd = None, entrypoint = None, tags = [], testonly = False, **kwargs):
+def oci_image(name, labels = None, annotations = None, env = None, cmd = None, entrypoint = None, tags = [], **kwargs):
"""Macro wrapper around [oci_image_rule](#oci_image_rule).
Allows labels and annotations to be provided as a dictionary, in addition to a text file.
@@ -45,6 +46,9 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
tags: Tags to propagate to targets declared by this macro.
**kwargs: other named arguments to [oci_image_rule](#oci_image_rule)
"""
+ forwarded_kwargs = propagate_common_rule_attributes(kwargs)
+ forwarded_kwargs.pop("tags", None)
+
if types.is_dict(annotations):
annotations_label = "_{}_write_annotations".format(name)
write_file(
@@ -52,7 +56,7 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
out = "_{}.annotations.txt".format(name),
content = ["{}={}".format(key, value) for (key, value) in annotations.items()],
tags = tags,
- testonly = testonly,
+ **forwarded_kwargs,
)
annotations = annotations_label
|
@reltuk we released bazel-lib yesterday including your change, so this should be unblocked now ;) |
…by oci_image and oci_tarball macros.
6e179b8
to
a903022
Compare
@alexeagle Thanks for the ping and the quick response! I took a pass at the dep bump + the change to the macros. Happy to split it up into separate PRs as well, if that's preferred. |
…le_attributes mechanism. forward common attributes in oci_push as well.
Took a pass at removing tags and also added forwarding common attributes for |
Thanks for your help :). |
I think you need to rebase and then run the command. |
Unfortunately, none of the following produced any updates:
I may get a chance to poke at it further in a bit :). |
docs/image.md
Outdated
@@ -118,7 +118,6 @@ This is similar to the same-named target created by rules_docker's `container_im | |||
| <a id="oci_image-env"></a>env | Environment variables provisioned by default to the running container. See documentation above. | <code>None</code> | | |||
| <a id="oci_image-cmd"></a>cmd | Command & argument configured by default in the running container. See documentation above. | <code>None</code> | | |||
| <a id="oci_image-entrypoint"></a>entrypoint | Entrypoint configured by default in the running container. See documentation above. | <code>None</code> | | |||
| <a id="oci_image-tags"></a>tags | Tags to propagate to targets declared by this macro. | <code>[]</code> | | |||
| <a id="oci_image-kwargs"></a>kwargs | other named arguments to [oci_image_rule](#oci_image_rule) | none | | |||
| <a id="oci_image-kwargs"></a>kwargs | other named arguments to [oci_image_rule](#oci_image_rule) and [common rule attribtes](https://bazel.build/reference/be/common-definitions#common-attributes). | none | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there's a typo in "attributes" (here and in four other locations in the PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that. Just took a pass at fixing it.
…392) Co-authored-by: Aaron Son <[email protected]>
As per #369, trying to put a test in an
oci_image
target by making ittestonly = True
is currently broken.This PR just adds the common rule attribute
testonly
to theoci_image
andoci_tarball
macros and forwards its value along to all the rules they instantiate.