rules_k8s
rules_k8s copied to clipboard
less targets generated
I might be missed where this is configured, but is there a way to configure k8s_object to not have all the other targets that hang off it?
We only use .create and .update and all the other targets produce cause us to build hundreds of extra targets, when we build the repository via npx bazel test ...
They are always created, https://github.com/bazelbuild/rules_k8s/blob/a84d15926a882129b724105039ef804b8cbc6eb5/k8s/object.bzl#L524
Yes that's the issue we have. We'd like to only build the targets that we actually use, .create and .update
The code you're looking for is here:
https://github.com/bazelbuild/rules_k8s/blob/0a04716c226d0173bf7035965d9010871d39142b/k8s/object.bzl#L496-L587
k8s_object is a macro (aka function) which calls stuff like:
https://github.com/bazelbuild/rules_k8s/blob/0a04716c226d0173bf7035965d9010871d39142b/k8s/object.bzl#L527
https://github.com/bazelbuild/rules_k8s/blob/0a04716c226d0173bf7035965d9010871d39142b/k8s/object.bzl#L539
that actually declare these targets. This would probably involve putting something into **kwargs and extracting it. For example something like:
# default to all of them
verbs = kwargs.get("verbs", ["describe", "apply", "replace", "delete", "create")
if "create" in verbs:
_k8s_object_create(...)
if "apply" in verbs:
_k8s_object_apply(...)
...
and you would change your usage to something like:
load("@rules_k8s//k8s:object.bzl", "k8s_object")
k8s_object(
name = "foo",
...
verbs = ["create", "delete"], # only create targets for these two verbs
)
Is this something you could contribute?
This sounds interesting if someone wants to take it on, otherwise I'm going to close this out as it is the current intended behavior.