bestit / flagception-bundle

Feature flags on steroids!
MIT License
210 stars 42 forks source link

Strategy #40

Closed migo315 closed 5 years ago

migo315 commented 6 years ago

Normally, the individual fields in the config.yml are an OR condition. In this example, the feature is enabled if the environment variable returns true or if the logged in user contains the ROLE_ADMIN role.

# config.yml

flagception:
    features:      
        feature_123:
            env: FOOBAR
            roles: ROLE_ADMIN

It would be interesting to be able to modify the strategy so that it becomes an AND condition. If you change the strategy and use the same example, the feature would only be enabled if the environment variable returns true AND the user contains the ROLE_ADMIN role.

# config.yml

flagception:
    features:      
        feature_123:
            env: FOOBAR
            roles: ROLE_ADMIN

        feature_345:
            env: FOOBAR
            roles: ROLE_ADMIN
            strategy: single # Overwrite the global strategy for this feature)

     # Set global for all (Default: single)            
     config:
         strategy: all

all => All defined conditions must match for activating this feature single => at least one condition must match for activating this feature

migo315 commented 5 years ago

I like the strategy idea but I think we have to decouple all activators instead of merging.