Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class FeatureFlagConstants:
GROUPS = "groups"

# Requirement type options
REQUIREMENT_TYPE_ALL = "all"
REQUIREMENT_TYPE_ANY = "any"
REQUIREMENT_TYPE_ALL = "All"
REQUIREMENT_TYPE_ANY = "Any"

# Telemetry properties
METADATA = "metadata"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,14 +906,15 @@ def map_keyvalue_to_featureflagvalue(keyvalue):
FeatureFlagConstants.REQUIREMENT_TYPE, None
)
if requirement_type:
if requirement_type.lower() not in (
FeatureFlagConstants.REQUIREMENT_TYPE_ALL,
FeatureFlagConstants.REQUIREMENT_TYPE_ANY,
):
# Requirement type is case insensitive.
if requirement_type.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ALL.lower():
conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = FeatureFlagConstants.REQUIREMENT_TYPE_ALL
elif requirement_type.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ANY.lower():
conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = FeatureFlagConstants.REQUIREMENT_TYPE_ANY
else:
raise ValidationError(
f"Feature '{feature_name}' must have an any/all requirement type."
f"Feature '{feature_name}' must have an Any/All requirement type."
)
conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = requirement_type

# Backend returns conditions: {client_filters: None} for flags with no conditions.
# No need to write empty conditions to key-values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,15 @@ def __read_features_from_msfm_schema(feature_flags_list):
FeatureFlagConstants.REQUIREMENT_TYPE, None
)
if requirement_type:
if requirement_type.lower() not in (
FeatureFlagConstants.REQUIREMENT_TYPE_ALL,
FeatureFlagConstants.REQUIREMENT_TYPE_ANY,
):
# Requirement type is case insensitive.
if requirement_type.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ALL.lower():
new_feature.conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = FeatureFlagConstants.REQUIREMENT_TYPE_ALL
elif requirement_type.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ANY.lower():
new_feature.conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = FeatureFlagConstants.REQUIREMENT_TYPE_ANY
else:
raise ValidationError(
f"Feature '{feature_id}' must have an any/all requirement type."
f"Feature '{feature_id}' must have an Any/All requirement type."
)
new_feature.conditions[
FeatureFlagConstants.REQUIREMENT_TYPE
] = requirement_type

if allocation := feature.get(FeatureFlagConstants.ALLOCATION, None):
new_feature.allocation = FeatureAllocation.convert_from_dict(allocation)
Expand Down Expand Up @@ -382,18 +381,16 @@ def __read_features_from_dotnet_schema(features_dict, feature_management_keyword
condition == feature_management_keywords.requirement_type and
condition_value
):
if condition_value.lower() not in (
FeatureFlagConstants.REQUIREMENT_TYPE_ALL,
FeatureFlagConstants.REQUIREMENT_TYPE_ANY,
):
if condition_value.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ALL.lower():
feature_flag_value.conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = FeatureFlagConstants.REQUIREMENT_TYPE_ALL
elif condition_value.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ANY.lower():
feature_flag_value.conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = FeatureFlagConstants.REQUIREMENT_TYPE_ANY
else:
raise ValidationError(
"Feature '{0}' must have an any/all requirement type. \n".format(
"Feature '{0}' must have an Any/All requirement type. \n".format(
str(k)
)
)
feature_flag_value.conditions[
FeatureFlagConstants.REQUIREMENT_TYPE
] = condition_value
else:
feature_flag_value.conditions[condition] = condition_value
if not enabled_for_found:
Expand Down
12 changes: 10 additions & 2 deletions src/azure-cli/azure/cli/command_modules/appconfig/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def set_feature(cmd,
default_conditions = {FeatureFlagConstants.CLIENT_FILTERS: []}

if requirement_type:
default_conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = requirement_type
default_conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = (
FeatureFlagConstants.REQUIREMENT_TYPE_ALL
if requirement_type.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ALL.lower()
else FeatureFlagConstants.REQUIREMENT_TYPE_ANY
)

default_value = {
FeatureFlagConstants.ID: feature,
Expand Down Expand Up @@ -125,7 +129,11 @@ def set_feature(cmd,
feature_flag_value.description = description

if requirement_type is not None:
feature_flag_value.conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = requirement_type
feature_flag_value.conditions[FeatureFlagConstants.REQUIREMENT_TYPE] = (
FeatureFlagConstants.REQUIREMENT_TYPE_ALL
if requirement_type.lower() == FeatureFlagConstants.REQUIREMENT_TYPE_ALL.lower()
else FeatureFlagConstants.REQUIREMENT_TYPE_ANY
)

set_kv = KeyValue(key=key,
label=label,
Expand Down
Loading