-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Adding an example for setting multiple fields based on one flag #200
base: main
Are you sure you want to change the base?
Conversation
Thanks for this PR, @chasain . I'm just seeing this now and will give it a thorough review soon. |
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.
This is a really interesting use of Starlark machinery.
How do you evaluate the importance of aspects in the implementation? Could the ice_cream
rule itself directly filter its deps' providers based on the flag to get similar results?
flavors = rule( | ||
implementation = _flavors_impl, | ||
attrs = { | ||
"flavors": attr.label_list(), |
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.
For completeness, I think attr
can restrict allowed deps to only those that provide FlavorProvider
, to be more explicit that this is only intended to be consumed by flavor
instances.
|
||
To test it out, cd to this directory and run the following: | ||
``` | ||
$ bazel build :ice_cream # => "vanilla is white" |
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.
Separate the output into distinct lines to look more realistic?
Friendly ping. |
Another ping, a year later. |
I built this example while trying to make rules_k8s a bit cleaner for us, it allows me to define something like
Then I can call
bazel run //some/deployment:object.apply --cluster=minikube
and substitute all the values from my cluster into the object.