cfpb / django-flags

Feature flags for Django projects
https://cfpb.github.io/django-flags/
Creative Commons Zero v1.0 Universal
260 stars 32 forks source link

Add support for flag metadata #67

Closed willbarton closed 4 years ago

willbarton commented 4 years ago

This PR supports specifying metadata for each feature flag in both the SettingsFlagsSource and the DatabaseFlagsSource, as well as get_flags and custom flag sources.

Flags defined in Django settings files can now be specified like this:

FLAGS = {
  'FLAG_WITH_METADATA': [
    {'condition': 'boolean', 'value': 'true'},
    {'help_text': 'a human-friendly flag description', 'category': 'a human-friendly category'},
  ],
}

There is a new model, FlagMetadata, added in this PR to add metadata in the admin.

To support that, this change will deprecate the previous behavior of flag sources' get_flags method, which was expected to return a dictionary, and instead expect a three-tuple of (flag, conditions, metadata).

Currently the metadata is not consumed anywhere — it does not change the way the Django admin for feature flags works, and isn't referenced there. It is intended for use in the admin of Wagtail Flags and in any other custom flag consumption/auditing/reporting. Metadata keys can be anything — there is not preference for particular keys in Django Flags. I anticipate that Wagtail Flags will make use of "category" and "help_text" which is why they're included in the examples here.

Scotchester commented 4 years ago

confused-travolta

Edit: Oh, possibly a consequence of changing the primary branch to main.

willbarton commented 4 years ago

Well, that and I don't really like this approach.