Merged
Conversation
4186309 to
2ebda9a
Compare
Contributor
|
Nice, thanks for making it work with the I've tested this locally and it works for me 👍 |
The FeatureService class can be initialized with single positional argument to hold the user. The user argument is optional and most features don't use it. Adding other arguments in the future would require callers to provide nil as a placeholder. Instead the initializer has been changed to take a keyword argument for user. All the callers have been updated to use this new format. This should make it easier to add new keywords in the future.
Add a new way to specify that feature flags should be per group
instead of set by environment variable.
To allow individual groups to have a feature flag, you need to do two
things.
Add the feature flag to the settings.yml file. For example, to add a
feature flag called branch_routing, follow these steps:
Add method to Group, called `branch_routing_enabled?`. You probably want
to add a new column to Group called `branch_routing_enabled` and rely on
the rails helper to add the `?` at the end. It should probably have a
default value of false.
Add a rake task to set/clear this value.
Add the following to the settings yaml config.
```yaml
features:
branch_routing:
enabled_by_group: true
```
Use FeatureService.new(group:
current_form.group).enabled?(:branch_routing) whenever you need to test
the feature flag.
The setting can be enabled for a whole environment, for example dev, in
the usual way:
```yaml
features:
branch_routing: true
```
This commit uses:
```
return group.send(:"#{feature_name}_enabled?")
```
in FeatureService#enabled? to check if the group has the feature. It
will raise an exception if this method is not defined, so the changes to
group should be made before adding the feature to the settings file.
Raising an exception rather than returning false was chosen to expose
issues earlier in development.
Add a new boolean column for enabling the branch_routing feature flag.
Add two tasks to enable and disable the branch feature for a specific group. Heavily inspired by #1645 Like the above PR, there are no tests.
Every call to check if the branch_routing feature is enabled now includes the current form's group. This change will allow us to set the feature flag to be enabled per group rather than for every environment.
Change the value of the feature setting for branch_routing to be enabled_by_group instead. This will allow the flag to be set per group in environments which have not overridden it.
2ebda9a to
1e57741
Compare
|
lfdebrux
approved these changes
Jan 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Add a feature flag for enabling advanced branching for specified groups
Trello card: https://trello.com/c/GgbE96M1/2083-enable-branch-routing-feature-in-production-for-an-internal-test-group
To begin with, we want to release the advanced branching features to a small number of users.
To do this, we are enabling some Groups to have the feature flag enabled, instead of enabling it for the whole environment. We still want the flag to be enabled in dev for all users and groups.
This PR adds a new way to specify that a feature flag value should be taken per group rather than set for the whole environment. See the commits for details.
This PR is heavily based off the changes @stephencdaly and feature team one did for file upload.
It's more complicated because the branching feature flag is used in more places, mainly views.
This PR replaces #1729
Things to consider when reviewing