Allow for dynamic feature flags (#6808)

* Allow for dynamic feature flags

Giving more control over feature flags, allowing administrator to define
custom logic around whether features are enabled for particular users /
roles.

The exposed function can be used for things like:
* progressive rollout of features (1%, 5%, 50%, 100%)
* experimentation
* role-based feature affectation (only admins see a particular feature)

* fix build

* Addressing comments

* Addressing @hughhh's comments
This commit is contained in:
Maxime Beauchemin
2019-02-27 15:11:38 -08:00
committed by GitHub
parent e0feec9117
commit 3ae02d1a54
5 changed files with 45 additions and 10 deletions

View File

@@ -190,10 +190,14 @@ class SupersetTestCase(unittest.TestCase):
raise Exception('run_sql failed')
return resp
@patch.dict('superset.feature_flags', {'FOO': True}, clear=True)
@patch.dict('superset._feature_flags', {'FOO': True}, clear=True)
def test_existing_feature_flags(self):
self.assertTrue(is_feature_enabled('FOO'))
@patch.dict('superset.feature_flags', {}, clear=True)
@patch.dict('superset._feature_flags', {}, clear=True)
def test_nonexistent_feature_flags(self):
self.assertFalse(is_feature_enabled('FOO'))
def test_feature_flags(self):
self.assertEquals(is_feature_enabled('foo'), 'bar')
self.assertEquals(is_feature_enabled('super'), 'set')