diff --git a/MODULE.bazel b/MODULE.bazel index 181a28ea..160ff9cf 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,7 +6,7 @@ module( compatibility_level = 1, ) -bazel_dep(name = "aspect_bazel_lib", version = "1.32.0") +bazel_dep(name = "aspect_bazel_lib", version = "1.35.0") bazel_dep(name = "bazel_skylib", version = "1.4.1") bazel_dep(name = "platforms", version = "0.0.5") diff --git a/docs/image.md b/docs/image.md index 2dba85e6..c64738a9 100644 --- a/docs/image.md +++ b/docs/image.md @@ -90,7 +90,7 @@ oci_image( ## oci_image
-oci_image(name, labels, annotations, env, cmd, entrypoint, tags, kwargs) +oci_image(name, labels, annotations, env, cmd, entrypoint, kwargs)Macro wrapper around [oci_image_rule](#oci_image_rule). @@ -118,7 +118,6 @@ This is similar to the same-named target created by rules_docker's `container_im | env | Environment variables provisioned by default to the running container. See documentation above. |
None
|
| cmd | Command & argument configured by default in the running container. See documentation above. | None
|
| entrypoint | Entrypoint configured by default in the running container. See documentation above. | None
|
-| tags | Tags to propagate to targets declared by this macro. | []
|
-| kwargs | other named arguments to [oci_image_rule](#oci_image_rule) | none |
+| kwargs | other named arguments to [oci_image_rule](#oci_image_rule) and [common rule attributes](https://bazel.build/reference/be/common-definitions#common-attributes). | none |
diff --git a/docs/push.md b/docs/push.md
index 1270875f..e2f1bb9a 100644
--- a/docs/push.md
+++ b/docs/push.md
@@ -134,7 +134,7 @@ oci_push(
## oci_push
-oci_push(name, remote_tags, tags, kwargs) +oci_push(name, remote_tags, kwargs)Macro wrapper around [oci_push_rule](#oci_push_rule). @@ -149,7 +149,6 @@ Allows the remote_tags attribute to be a list of strings in addition to a text f | :------------- | :------------- | :------------- | | name | name of resulting oci_push_rule | none | | remote_tags | a list of tags to apply to the image after pushing, or a label of a file containing tags one-per-line. See [stamped_tags](https://github.com/bazel-contrib/rules_oci/blob/main/examples/push/stamp_tags.bzl) as one example of a way to produce such a file. |
None
|
-| tags | Tags to propagate to targets declared by this macro. | []
|
-| kwargs | other named arguments to [oci_push_rule](#oci_push_rule). | none |
+| kwargs | other named arguments to [oci_push_rule](#oci_push_rule) and [common rule attributes](https://bazel.build/reference/be/common-definitions#common-attributes). | none |
diff --git a/oci/defs.bzl b/oci/defs.bzl
index e5e4cc1c..154c1536 100644
--- a/oci/defs.bzl
+++ b/oci/defs.bzl
@@ -9,6 +9,7 @@ load("@rules_oci//oci:defs.bzl", ...)
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
+load("@aspect_bazel_lib//lib:utils.bzl", "propagate_common_rule_attributes")
load("@bazel_skylib//lib:types.bzl", "types")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("//oci/private:image.bzl", _oci_image = "oci_image")
@@ -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 = [], **kwargs):
+def oci_image(name, labels = None, annotations = None, env = None, cmd = None, entrypoint = None, **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.
@@ -42,16 +43,18 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
env: Environment variables provisioned by default to the running container. See documentation above.
cmd: Command & argument configured by default in the running container. See documentation above.
entrypoint: Entrypoint configured by default in the running container. See documentation above.
- tags: Tags to propagate to targets declared by this macro.
- **kwargs: other named arguments to [oci_image_rule](#oci_image_rule)
+ **kwargs: other named arguments to [oci_image_rule](#oci_image_rule) and
+ [common rule attributes](https://bazel.build/reference/be/common-definitions#common-attributes).
"""
+ forwarded_kwargs = propagate_common_rule_attributes(kwargs)
+
if types.is_dict(annotations):
annotations_label = "_{}_write_annotations".format(name)
write_file(
name = annotations_label,
out = "_{}.annotations.txt".format(name),
content = ["{}={}".format(key, value) for (key, value) in annotations.items()],
- tags = tags,
+ **forwarded_kwargs,
)
annotations = annotations_label
@@ -61,7 +64,7 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
name = labels_label,
out = "_{}.labels.txt".format(name),
content = ["{}={}".format(key, value) for (key, value) in labels.items()],
- tags = tags,
+ **forwarded_kwargs,
)
labels = labels_label
@@ -71,7 +74,7 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
name = env_label,
out = "_{}.env.txt".format(name),
content = ["{}={}".format(key, value) for (key, value) in env.items()],
- tags = tags,
+ **forwarded_kwargs,
)
env = env_label
@@ -81,7 +84,7 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
name = env_label,
out = "_{}.env.txt".format(name),
content = ["{}={}".format(key, value) for (key, value) in env.items()],
- tags = tags,
+ **forwarded_kwargs,
)
env = env_label
@@ -91,7 +94,7 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
name = cmd_label,
out = "_{}.cmd.txt".format(name),
content = [",".join(cmd)],
- tags = tags,
+ **forwarded_kwargs,
)
cmd = cmd_label
@@ -101,7 +104,7 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
name = entrypoint_label,
out = "_{}.entrypoint.txt".format(name),
content = [",".join(entrypoint)],
- tags = tags,
+ **forwarded_kwargs,
)
entrypoint = entrypoint_label
@@ -112,7 +115,6 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
env = env,
cmd = cmd,
entrypoint = entrypoint,
- tags = tags,
**kwargs
)
@@ -122,14 +124,14 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
name = "_{}_index_json".format(name),
directory = name,
path = "index.json",
- tags = tags,
+ **forwarded_kwargs,
)
copy_file(
name = "_{}_index_json_cp".format(name),
src = "_{}_index_json".format(name),
out = "_{}_index.json".format(name),
- tags = tags,
+ **forwarded_kwargs,
)
# Matches the [name].digest target produced by rules_docker container_image
@@ -139,10 +141,10 @@ def oci_image(name, labels = None, annotations = None, env = None, cmd = None, e
srcs = ["_{}_index.json".format(name)],
filter = """.manifests[0].digest""",
out = name + ".json.sha256", # path chosen to match rules_docker for easy migration
- tags = tags,
+ **forwarded_kwargs,
)
-def oci_push(name, remote_tags = None, tags = [], **kwargs):
+def oci_push(name, remote_tags = None, **kwargs):
"""Macro wrapper around [oci_push_rule](#oci_push_rule).
Allows the remote_tags attribute to be a list of strings in addition to a text file.
@@ -153,27 +155,28 @@ def oci_push(name, remote_tags = None, tags = [], **kwargs):
or a label of a file containing tags one-per-line.
See [stamped_tags](https://github.com/bazel-contrib/rules_oci/blob/main/examples/push/stamp_tags.bzl)
as one example of a way to produce such a file.
- tags: Tags to propagate to targets declared by this macro.
- **kwargs: other named arguments to [oci_push_rule](#oci_push_rule).
+ **kwargs: other named arguments to [oci_push_rule](#oci_push_rule) and
+ [common rule attributes](https://bazel.build/reference/be/common-definitions#common-attributes).
"""
+ forwarded_kwargs = propagate_common_rule_attributes(kwargs)
+
if types.is_list(remote_tags):
tags_label = "_{}_write_tags".format(name)
write_file(
name = tags_label,
out = "_{}.tags.txt".format(name),
content = remote_tags,
- tags = tags,
+ **forwarded_kwargs,
)
remote_tags = tags_label
oci_push_rule(
name = name,
remote_tags = remote_tags,
- tags = tags,
**kwargs
)
-def oci_tarball(name, repo_tags = None, tags = [], **kwargs):
+def oci_tarball(name, repo_tags = None, **kwargs):
"""Macro wrapper around [oci_tarball_rule](#oci_tarball_rule).
Allows the repo_tags attribute to be a list of strings in addition to a text file.
@@ -184,22 +187,23 @@ def oci_tarball(name, repo_tags = None, tags = [], **kwargs):
or a label of a file containing tags one-per-line.
See [stamped_tags](https://github.com/bazel-contrib/rules_oci/blob/main/examples/push/stamp_tags.bzl)
as one example of a way to produce such a file.
- tags: Tags to propagate to targets declared by this macro.
- **kwargs: other named arguments to [oci_tarball_rule](#oci_tarball_rule).
+ **kwargs: other named arguments to [oci_tarball_rule](#oci_tarball_rule) and
+ [common rule attributes](https://bazel.build/reference/be/common-definitions#common-attributes).
"""
+ forwarded_kwargs = propagate_common_rule_attributes(kwargs)
+
if types.is_list(repo_tags):
tags_label = "_{}_write_tags".format(name)
write_file(
name = tags_label,
out = "_{}.tags.txt".format(name),
content = repo_tags,
- tags = tags,
+ **forwarded_kwargs,
)
repo_tags = tags_label
oci_tarball_rule(
name = name,
repo_tags = repo_tags,
- tags = tags,
**kwargs
)
diff --git a/oci/dependencies.bzl b/oci/dependencies.bzl
index 5626323b..1cfa857a 100644
--- a/oci/dependencies.bzl
+++ b/oci/dependencies.bzl
@@ -29,7 +29,7 @@ def rules_oci_dependencies():
http_archive(
name = "aspect_bazel_lib",
- sha256 = "f1c181b910f821072f38ee45bb87db6b56275458c7f832c54c54ba6334119eca",
- strip_prefix = "bazel-lib-1.32.0",
- url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.32.0/bazel-lib-v1.32.0.tar.gz",
+ sha256 = "e9505bd956da64b576c433e4e41da76540fd8b889bbd17617fe480a646b1bfb9",
+ strip_prefix = "bazel-lib-1.35.0",
+ url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.35.0/bazel-lib-v1.35.0.tar.gz",
)