Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppConfig] appconfig feature list/show and appconfig kv import/export: Support microsoft feature management schema #30376

Merged
merged 49 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
a242281
Support new ms fm schema
Nov 13, 2024
bc99149
update tests
Nov 13, 2024
9d077e9
update imports
Nov 13, 2024
52c2d31
update flag properties
Nov 13, 2024
90d876a
Merge branch 'cwanjau/supportFFV2Schema' of https://github.com/Christ…
Nov 13, 2024
c846079
update feature properties
Nov 13, 2024
9396e6d
update feature models
Nov 14, 2024
60b9d0f
update test
Nov 14, 2024
ec96b1a
update test files
Nov 14, 2024
ab36eeb
update feature models
Nov 14, 2024
e5fbdc3
update feature models
Nov 14, 2024
9ec9e81
update feature models
Nov 14, 2024
2dd09da
update tests
Nov 15, 2024
e9dc52c
update filter
Nov 15, 2024
1d0565b
update boolean value
Nov 15, 2024
1e1c580
update tests
Nov 15, 2024
359e19e
Merge branch 'cwanjau/supportFFV2Schema' of https://github.com/Christ…
Nov 15, 2024
b6e4060
update tests
Nov 18, 2024
62d2157
fix style issues
Nov 18, 2024
ddfbfcb
update default compatibility mode
Nov 18, 2024
bd57035
Push test recordings
Nov 18, 2024
60f087c
Revert "Push test recordings"
Nov 18, 2024
5203b67
resolve merge conflicts
Nov 18, 2024
2db2b9c
push test recordings
Nov 18, 2024
e31f034
resolve test failures
Nov 18, 2024
a996a91
add cli tests
Nov 20, 2024
0fba17f
add invalid variants test
Nov 20, 2024
93a985f
add tests
Nov 20, 2024
8fb54d3
address comments
Nov 21, 2024
a3dc72b
resolve styling issue
Nov 21, 2024
46f4f21
Address comments
Nov 25, 2024
1a4e73e
Merge branch 'cwanjau/supportFFV2Schema' of https://github.com/Christ…
Nov 25, 2024
4719333
renamed variable
Nov 27, 2024
9f2686b
address class comments
Dec 3, 2024
6af239a
update setting feature as keyvalue
Dec 3, 2024
d7cd6e2
push test recordings
Dec 3, 2024
cded062
address comments
Dec 9, 2024
4765742
resolve merge conflicts
Dec 16, 2024
e33ba49
resolve comments
Dec 17, 2024
bf0c7be
address comments
Dec 18, 2024
3a0b2ba
update according to comments
Jan 7, 2025
b683b90
fix styling issues
Jan 7, 2025
8972437
update tests
Jan 7, 2025
bc6bdbc
address comments
Jan 8, 2025
d7f33f5
code improvements
Jan 8, 2025
550aabd
update spelling
Jan 16, 2025
03ce314
push tests
Jan 17, 2025
3c01345
Update export to file help message
Jan 22, 2025
1b294a1
Update export to file help message
Jan 22, 2025
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 @@ -21,13 +21,43 @@ class FeatureFlagConstants:
CLIENT_FILTERS = "client_filters"
REQUIREMENT_TYPE = "requirement_type"
DISPLAY_NAME = "display_name"
FILTER_NAME = "name"
NAME = "name"
FILTER_PARAMETERS = "parameters"
ALLOCATION = "allocation"
TELEMETRY = "telemetry"
VARIANTS = "variants"

# allocation properties
GROUP = "group"
USER = "user"
PERCENTILE = "percentile"
DEFAULT_WHEN_ENABLED = "default_when_enabled"
DEFAULT_WHEN_DISABLED = "default_when_disabled"
SEED = "seed"

# variant properties
VARIANT = "variant"
VARIANT_CONFIGURATION_VALUE = "configuration_value"
VARIANT_STATUS_OVERRIDE = "status_override"

# percentile properties
FROM = "from"
TO = "to"

# allocation user/group properties
USERS = "users"
GROUPS = "groups"

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

# Telemetry properties
METADATA = "metadata"

# feature flags key
FEATURE_FLAGS_KEY = "feature_flags"


class KeyVaultConstants:
KEYVAULT_CONTENT_TYPE = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# pylint: disable=line-too-long, too-few-public-methods

import json
import os

from knack.util import CLIError
from knack.log import get_logger

from ._constants import CompareFields, JsonDiff, AppServiceConstants
from ._featuremodels import (map_keyvalue_to_featureflag, custom_serialize_conditions, is_feature_flag)
from ._featuremodels import (custom_serialize_allocation, custom_serialize_variants, map_keyvalue_to_featureflag, custom_serialize_conditions, custom_serialize_telemetry, is_feature_flag)
from ._utils import is_json_content_type

logger = get_logger(__name__)
Expand Down Expand Up @@ -153,15 +154,37 @@ def serialize(obj):

# Feature flag format: {"feature": <feature-name>, "state": <on/off>, "conditions": <conditions-dict>}
if is_feature_flag(obj):
feature = map_keyvalue_to_featureflag(obj)

# State property doesn't make sense in feature flag version 2 schema beacuse of the added properties - variants, allocation, telemetry
# The State property only exists in the CLI, we should move to showing enabled property instead as the other clients
# As we move to showing the enabled property, we will show the state property in the CLI only if compatibility mode is true
env_compatibility_mode = os.environ.get("AZURE_APPCONFIG_FM_COMPATIBLE", True)
compatibility_mode = str(env_compatibility_mode).lower() == "true"

feature = map_keyvalue_to_featureflag(obj, hide_enabled=compatibility_mode)
# name
feature_json = {'feature': feature.name}
# state
feature_json['state'] = feature.state
if hasattr(feature, 'state'):
feature_json['state'] = feature.state
# enabled
if hasattr(feature, 'enabled'):
feature_json['enabled'] = feature.enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we display enabled property instead of state, we must also display the number of filters/variants and if telemetry is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we currently display variants/filters and telemetry for both scenarios with state property and enabled property.

# description
feature_json['description'] = feature.description
if feature.description is not None:
feature_json['description'] = feature.description
# conditions
feature_json['conditions'] = custom_serialize_conditions(feature.conditions)
if feature.conditions:
feature_json['conditions'] = custom_serialize_conditions(feature.conditions)
# allocation
if feature.allocation:
feature_json['allocation'] = custom_serialize_allocation(feature.allocation)
# variants
if feature.variants:
feature_json['variants'] = custom_serialize_variants(feature.variants)
# telemetry
if feature.telemetry:
feature_json['telemetry'] = custom_serialize_telemetry(feature.telemetry)

return feature_json

Expand Down
Loading
Loading