This guide helps you get started adding your feature behind a feature flag in Grafana.
- Define the feature toggle in registry.go. To see what each feature stage means, look at the comments here. If you are a community member, use the CODEOWNERS file to determine which team owns the package you are updating.
- Run the go tests mentioned at the top of this file. This will generate all the additional files needed:
toggles_gen
for the backend,grafana-data
for the frontend, and docs. You can run the test by runninggo test ./pkg/services/featuremgmt/...
. This will say the tests failed the first time, but it will have generated the right code. If you re-run the tests, it will pass.
Once your feature toggle is defined, you can then wrap your feature around a check if the feature flag is enabled on that Grafana instance. Here are examples of how to do that: