Skip to content

Commit fedaa23

Browse files
committed
Adjust feature flag metadata
1 parent 740140d commit fedaa23

File tree

7 files changed

+52
-30
lines changed

7 files changed

+52
-30
lines changed

ansible_base/feature_flags/definitions/feature_flags.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
- name: FEATURE_INDIRECT_NODE_COUNTING_ENABLED
22
ui_name: Indirect Node Counting
3-
visibility: public
3+
visibility: False
44
condition: boolean
55
value: 'False'
6-
support_level: NOT_FOR_PRODUCTION
6+
support_level: TECHNICAL_PREVIEW
77
description: TBD
88
support_url: https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/
99
labels:
1010
- controller
1111
- name: FEATURE_POLICY_AS_CODE_ENABLED
1212
ui_name: Policy as Code
13-
visibility: public
13+
visibility: False
1414
condition: boolean
1515
value: 'False'
16-
support_level: NOT_FOR_PRODUCTION
16+
support_level: TECHNICAL_PREVIEW
1717
description: TBD
1818
support_url: https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/
1919
labels:
2020
- controller
2121
- name: FEATURE_EDA_ANALYTICS_ENABLED
2222
ui_name: Event-Driven Ansible Analytics
23-
visibility: public
23+
visibility: False
2424
condition: boolean
2525
value: 'False'
26-
support_level: NOT_FOR_PRODUCTION
26+
support_level: TECHNICAL_PREVIEW
2727
description: TBD
2828
support_url: https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/
2929
labels:
3030
- eda
3131
- name: FEATURE_GATEWAY_IPV6_USAGE_ENABLED
3232
ui_name: Gateway IPv6 Usage
33-
visibility: private
33+
visibility: False
3434
condition: boolean
3535
value: 'False'
36-
support_level: NOT_FOR_PRODUCTION
36+
support_level: TECHNICAL_PREVIEW
3737
description: TBD
3838
support_url: https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/
3939
labels:
4040
- gateway
4141
- name: FEATURE_GATEWAY_CREATE_CRC_SERVICE_TYPE_ENABLED
4242
ui_name: Gateway Create CRC Service Type
43-
visibility: private
43+
visibility: False
4444
condition: boolean
4545
value: 'False'
46-
support_level: NOT_FOR_PRODUCTION
46+
support_level: TECHNICAL_PREVIEW
4747
description: TBD
4848
support_url: https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/
4949
labels:
5050
- gateway
5151
- name: FEATURE_DISPATCHERD_ENABLED
5252
ui_name: AAP Dispatcherd
53-
visibility: private
53+
visibility: False
5454
condition: boolean
5555
value: 'False'
56-
support_level: NOT_FOR_PRODUCTION
56+
support_level: TECHNICAL_PREVIEW
5757
description: TBD
5858
support_url: https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/
5959
labels:

ansible_base/feature_flags/definitions/schema.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
},
1919
"visibility": {
2020
"description": "Controls whether the feature is visible in the UI.",
21-
"type": "string",
22-
"enum": ["public", "private"]
21+
"type": "boolean"
2322
},
2423
"condition": {
2524
"description": "The type of condition for the feature flag's value. Currently only boolean is supported.",
@@ -35,9 +34,8 @@
3534
"description": "The level of support provided for this feature.",
3635
"type": "string",
3736
"enum": [
38-
"NOT_FOR_USE",
39-
"NOT_FOR_PRODUCTION",
40-
"READY_FOR_PRODUCTION"
37+
"TECHNICAL_PREVIEW",
38+
"DEVELOPER_PREVIEW"
4139
]
4240
},
4341
"description": {

ansible_base/feature_flags/flag_source.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
from flags.sources import Condition
33

44

5+
class DatabaseCondition(Condition):
6+
"""Condition that includes the AAPFlags database object
7+
This is required to ensure that enable_flag/disable_flag calls
8+
can work as expected, with the custom flag objects
9+
"""
10+
11+
def __init__(self, condition, value, required=False, obj=None):
12+
super().__init__(condition, value, required=required)
13+
self.obj = obj
14+
15+
516
class AAPFlagSource(object):
17+
"""The customer AAP flag source, retrieves a list of all flags in the database"""
618

719
def get_queryset(self):
820
aap_flags = apps.get_model('dab_feature_flags', 'AAPFlag')
@@ -13,5 +25,5 @@ def get_flags(self):
1325
for o in self.get_queryset():
1426
if o.name not in flags:
1527
flags[o.name] = []
16-
flags[o.name].append(Condition(o.condition, o.value, required=o.required))
28+
flags[o.name].append(DatabaseCondition(o.condition, o.value, required=o.required, obj=o))
1729
return flags

ansible_base/feature_flags/migrations/0001_initial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.17 on 2025-06-06 16:22
1+
# Generated by Django 4.2.21 on 2025-06-17 20:08
22

33
import ansible_base.feature_flags.models.aap_flag
44
from django.conf import settings
@@ -26,8 +26,8 @@ class Migration(migrations.Migration):
2626
('condition', models.CharField(default='boolean', help_text='Used to specify a condition, which if met, will enable the feature flag.', max_length=64)),
2727
('value', models.CharField(default='False', help_text='The value used to evaluate the conditional specified.', max_length=127)),
2828
('required', models.BooleanField(default=False, help_text="If multiple conditions are required to be met to enable a feature flag, 'required' can be used to specify the necessary conditionals.")),
29-
('support_level', models.CharField(choices=[('NOT_FOR_USE', 'Not for use'), ('NOT_FOR_PRODUCTION', 'Not for production'), ('READY_FOR_PRODUCTION', 'Ready for production')], help_text='The support criteria for the feature flag. Must be one of (NOT_FOR_USE, NOT_FOR_PRODUCTION, READY_FOR_PRODUCTION).', max_length=25)),
30-
('visibility', models.CharField(choices=[('public', 'public'), ('private', 'private')], help_text='The visibility level of the feature flag. If private, flag is hidden.', max_length=20)),
29+
('support_level', models.CharField(choices=[('DEVELOPER_PREVIEW', 'Developer Preview'), ('TECHNICAL_PREVIEW', 'Technical Preview')], help_text='The support criteria for the feature flag. Must be one of (DEVELOPER_PREVIEW or TECHNICAL_PREVIEW).', max_length=25)),
30+
('visibility', models.BooleanField(default=False, help_text='The visibility of the feature flag. If false, flag is hidden.')),
3131
('toggle_type', models.CharField(choices=[('install-time', 'install-time'), ('run-time', 'run-time')], default='run-time', help_text="Details whether a flag is toggle-able at run-time or install-time. (Default: 'run-time').", max_length=20)),
3232
('description', models.CharField(default='', help_text='A detailed description giving an overview of the feature flag.', max_length=500)),
3333
('support_url', models.CharField(blank=True, default='', help_text='A link to the documentation support URL for the feature', max_length=250)),

ansible_base/feature_flags/models/aap_flag.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,13 @@ def __str__(self):
4747
support_level = models.CharField(
4848
max_length=25,
4949
null=False,
50-
help_text=_("The support criteria for the feature flag. Must be one of (NOT_FOR_USE, NOT_FOR_PRODUCTION, READY_FOR_PRODUCTION)."),
51-
choices=(('NOT_FOR_USE', 'Not for use'), ('NOT_FOR_PRODUCTION', 'Not for production'), ('READY_FOR_PRODUCTION', 'Ready for production')),
50+
help_text=_("The support criteria for the feature flag. Must be one of (DEVELOPER_PREVIEW or TECHNICAL_PREVIEW)."),
51+
choices=(('DEVELOPER_PREVIEW', 'Developer Preview'), ('TECHNICAL_PREVIEW', 'Technical Preview')),
5252
blank=False,
5353
)
54-
visibility = models.CharField(
55-
max_length=20,
56-
null=False,
57-
choices=[('public', 'public'), ('private', 'private')],
58-
help_text=_("The visibility level of the feature flag. If private, flag is hidden."),
59-
blank=False,
54+
visibility = models.BooleanField(
55+
default=False,
56+
help_text=_("The visibility of the feature flag. If false, flag is hidden."),
6057
)
6158
toggle_type = models.CharField(
6259
max_length=20,

docs/apps/feature_flags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ An example flag could resemble -
5757
```yaml
5858
- name: FEATURE_FOO_ENABLED
5959
ui_name: Foo
60-
visibility: public
60+
visibility: True
6161
condition: boolean
6262
value: 'False'
6363
support_level: NOT_FOR_PRODUCTION

test_app/tests/feature_flags/models/test_aap_flag.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from django.conf import settings
3+
from flags.state import disable_flag, enable_flag, flag_state
34

45
from ansible_base.feature_flags.models import AAPFlag
56
from ansible_base.feature_flags.utils import feature_flags_list
@@ -48,3 +49,17 @@ def test_feature_flag_database_setting_override(feature_flag, value):
4849
create_initial_data()
4950
flag = AAPFlag.objects.get(name=feature_flag)
5051
assert flag.value == str(value)
52+
53+
54+
@pytest.mark.django_db
55+
def test_enable_and_disable_flag_functions(aap_flags):
56+
flag_name = "FEATURE_INDIRECT_NODE_COUNTING_ENABLED"
57+
# Assert Initial State
58+
assert flag_state(flag_name) is False
59+
60+
# Ensure flag can be enabled via django-flags enable_flag function
61+
enable_flag(flag_name)
62+
assert flag_state(flag_name) is True
63+
# Ensure flag can be disabled via django-flags enable_flag function
64+
disable_flag(flag_name)
65+
assert flag_state(flag_name) is False

0 commit comments

Comments
 (0)