-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We are installing the FlipFlop gem to enable us to use feature flags with a lower barrier to entry that the current process of using user permissions. The FlipFlop gem can store feature flag information inside the Whitehall database, meaning that we no longer have to create permissions inside of signon to deploy code without releasing it to users. We have disabled the cookie strategy because our main use case at the moment is toggling features on and off in different environments, but we may consider using it in future if our needs change. We have also only enabled the Flipflop user interface in local development environments. Developers will use the rake task provided by the library to toggle features in cloud environments. This commit also switches the FlipFlop strategy to use an in-memory store for feature flags and makes the flag data available to test cases.
- Loading branch information
Showing
9 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Flipflop.configure do | ||
# Strategies will be used in the order listed here. | ||
strategy :active_record | ||
strategy :default | ||
|
||
# Other strategies: | ||
# | ||
# strategy :sequel | ||
# strategy :redis | ||
# | ||
# strategy :query_string | ||
# strategy :session | ||
# | ||
# strategy :my_strategy do |feature| | ||
# # ... your custom code here; return true/false/nil. | ||
# end | ||
|
||
# Declare your features, e.g: | ||
# | ||
# feature :world_domination, | ||
# default: true, | ||
# description: "Take over the world." | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateFeatures < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :flipflop_features do |t| | ||
t.string :key, null: false | ||
t.boolean :enabled, null: false, default: false | ||
|
||
t.timestamps null: false | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Feature Flags | ||
|
||
Feature flags in Whitehall are managed using the [FlipFlop gem](https://github.com/voormedia/flipflop). The gem is currently | ||
configured so that only the ActiveRecord and default strategies are active. | ||
|
||
## Toggling Feature Flags | ||
|
||
In local development environments, a UI is available to make it easy to toggle feature flags on and off during development. | ||
The UI can be accessed at http://whitehall-admin.dev.gov.uk/flipflop. To toggle feature flags in non-local environments, the | ||
rake task provided by FlipFlop can be used, e.g. | ||
|
||
```bash | ||
bundle exec rake flipflop:turn_on[new_feature,active_record] # Enables the new feature with the Active Record strategy | ||
bundle exec rake flipflop:turn_off[new_feature,active_record] # Disables the new feature with the Active Record strategy | ||
``` | ||
|
||
## Testing with Feature Flags | ||
|
||
Feature flags are made accessible via the [`feature_flags`] helper on `ActionController::TestCase`. | ||
|
||
To toggle a feature flag in your controller test: | ||
|
||
```ruby | ||
feature_flags.switch! :your_feature, true | ||
``` |
This file contains 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