Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chasain
Copy link

@chasain chasain commented Apr 20, 2021

I built this example while trying to make rules_k8s a bit cleaner for us, it allows me to define something like

clusters(name = "cluster", clusters = [":minikube"])
cluster(
  name = "minikube",
  image_chroot = "localhost:5000",
  ...
)

Then I can call bazel run //some/deployment:object.apply --cluster=minikube and substitute all the values from my cluster into the object.

@gregestren
Copy link
Collaborator

Thanks for this PR, @chasain . I'm just seeing this now and will give it a thorough review soon.

@gregestren gregestren self-requested a review July 26, 2021 22:07
@gregestren gregestren self-assigned this Jul 26, 2021
Copy link
Collaborator

@gregestren gregestren left a 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(),
Copy link
Collaborator

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"
Copy link
Collaborator

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?

@aiuto
Copy link
Contributor

aiuto commented Apr 19, 2022

Friendly ping.

@aiuto
Copy link
Contributor

aiuto commented Apr 5, 2023

Another ping, a year later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants