Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Proposal: Flag-based conditions for logical combinations #86

Open
chosak opened this issue Nov 30, 2021 · 0 comments
Open

Proposal: Flag-based conditions for logical combinations #86

chosak opened this issue Nov 30, 2021 · 0 comments

Comments

@chosak
Copy link
Member

chosak commented Nov 30, 2021

Right now it's not easily possible to combine conditions using and/or logic, for example, enabling a flag if A and B but not (C or D). This is possible using custom conditions, but that requires writing custom code.

As a workaround, I wonder if it would work to introduce the concept of flag-based conditions, something like:

@register("flag_enabled", validator=valid_flag_name)
def flag_enabled_condition(flag_name, **kwargs):
    return flag_enabled(flag_name, **kwargs)

@register("flag_disabled", validator=valid_flag_name)
def flag_disabled_condition(flag_name, **kwargs):
    return flag_disabled(flag_name, **kwargs)

(This assumes some definition of valid_flag_name that's a regex of some kind - although in docs and by convention we tend to use SCREAMING_SNAKE_CASE, but technically are there any practical limitations on flag names? So perhaps a validator isn't even needed.)

This would allow you to define some flag FOO as C or D and then some other flag BAR as A and B and (FOO disabled).

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

No branches or pull requests

1 participant