Skip to content

Commit

Permalink
{AppConfig} az appconfig: Update azure appconfiguration sdk to versio…
Browse files Browse the repository at this point in the history
…n 1.7.0 (#29749)
  • Loading branch information
albertofori authored Sep 24, 2024
1 parent a6e5075 commit 570a354
Show file tree
Hide file tree
Showing 34 changed files with 29,576 additions and 28,588 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FeatureFlagConstants:
CONDITIONS = "conditions"
CLIENT_FILTERS = "client_filters"
REQUIREMENT_TYPE = "requirement_type"
DISPLAY_NAME = "display_name"
FILTER_NAME = "name"
FILTER_PARAMETERS = "parameters"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,23 @@ def __init__(self,
id_,
description=None,
enabled=None,
conditions=None):
conditions=None,
display_name=None):
default_conditions = {FeatureFlagConstants.CLIENT_FILTERS: []}

self.id = id_
self.description = "" if description is None else description
self.enabled = enabled if enabled else False
self.conditions = conditions if conditions else default_conditions
self.display_name = display_name

def __repr__(self):
featureflagvalue = {
FeatureFlagConstants.ID: self.id,
FeatureFlagConstants.DESCRIPTION: self.description,
FeatureFlagConstants.ENABLED: self.enabled,
FeatureFlagConstants.CONDITIONS: custom_serialize_conditions(self.conditions)
FeatureFlagConstants.CONDITIONS: custom_serialize_conditions(self.conditions),
FeatureFlagConstants.DISPLAY_NAME: self.display_name
}

return json.dumps(featureflagvalue, indent=2, ensure_ascii=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def __read_kv_from_app_service(cmd, appservice_account, prefix_to_add="", conten
# this throws an exception for invalid format of secret identifier
parse_key_vault_id(source_id=secret_identifier)
kv = KeyValue(key=key,
value=json.dumps({"uri": secret_identifier}, ensure_ascii=False, separators=(',', ':')),
value=json.dumps({"uri": secret_identifier}, ensure_ascii=False),
tags=tags,
content_type=KeyVaultConstants.KEYVAULT_CONTENT_TYPE)
key_values.append(kv)
Expand Down Expand Up @@ -909,12 +909,12 @@ def __validate_import_feature_flag(kv):
if kv and validate_import_feature_key(kv.key):
try:
ff = json.loads(kv.value)
if FEATURE_FLAG_PROPERTIES == ff.keys():
if FEATURE_FLAG_PROPERTIES.intersection(ff.keys()) == FEATURE_FLAG_PROPERTIES:
return validate_import_feature(ff[FeatureFlagConstants.ID])

logger.warning("The feature flag with key '{%s}' is not a valid feature flag. It will not be imported.", kv.key)
logger.warning("The feature flag with key '%s' is not a valid feature flag. It will not be imported.", kv.key)
except JSONDecodeError as exception:
logger.warning("The feature flag with key '{%s}' is not in a valid JSON format. It will not be imported.\n{%s}", kv.id, str(exception))
logger.warning("The feature flag with key '%s' is not in a valid JSON format. It will not be imported.\n%s", kv.key, str(exception))
return False


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def convert_keyvalue_to_configurationsetting(keyvalue=None):
label=keyvalue.label,
content_type=keyvalue.content_type,
value=keyvalue.value,
last_modified=keyvalue.last_modified,
tags=keyvalue.tags,
read_only=keyvalue.locked,
etag=keyvalue.etag)
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def set_keyvault(cmd,
endpoint=None):
azconfig_client = get_appconfig_data_client(cmd, name, connection_string, auth_mode, endpoint)

keyvault_ref_value = json.dumps({"uri": secret_identifier}, ensure_ascii=False, separators=(',', ':'))
keyvault_ref_value = json.dumps({"uri": secret_identifier}, ensure_ascii=False)
retry_times = 3
retry_interval = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"items": [
{
"key": ".appconfig.featureflag/beta-enabled",
"value": "{\"id\":\"custom-feature-beta-enabled\",\"description\":\"The flag indicates whether the beta feature is enabled for the user.\",\"enabled\":true,\"conditions\":{\"client_filters\":[]}}",
"value": "{\"id\": \"custom-feature-beta-enabled\", \"description\": \"The flag indicates whether the beta feature is enabled for the user.\", \"enabled\": true, \"conditions\": {\"client_filters\": []}, \"display_name\": null}",
"label": "beta-feature",
"content_type": "application/vnd.microsoft.appconfig.ff+json;charset=utf-8",
"tags": {}
},
{
"key": ".appconfig.featureflag/bool-feature",
"value": "{\"id\":\"bool-feature\",\"description\":\"It is a boolean feature\",\"enabled\":true,\"conditions\":{\"client_filters\":[]}}",
"value": "{\"id\": \"bool-feature\", \"description\": \"It is a boolean feature\", \"enabled\": true, \"conditions\": {\"client_filters\": []}, \"display_name\": null}",
"label": null,
"content_type": "application/vnd.microsoft.appconfig.ff+json;charset=utf-8",
"tags": {}
},
{
"key": ".appconfig.featureflag/theta-enabled",
"value": "{\"id\":\"customer-theta-enabled\",\"description\":\"This feature describes whether a theta feature is enabled for the customers.\",\"enabled\":true,\"conditions\":{\"client_filters\":[{\"name\":\"Microsoft.Targeting\",\"parameters\":{\"Audience\":{\"Users\":[],\"Groups\":[],\"DefaultRolloutPercentage\":90}}}]}}",
"value": "{\"id\": \"customer-theta-enabled\", \"description\": \"This feature describes whether a theta feature is enabled for the customers.\", \"enabled\": true, \"conditions\": {\"client_filters\": [{\"name\": \"Microsoft.Targeting\", \"parameters\": {\"Audience\": {\"Users\": [], \"Groups\": [], \"DefaultRolloutPercentage\": 90}}}]}, \"display_name\": null}",
"label": "theta-enabled-label",
"content_type": "application/vnd.microsoft.appconfig.ff+json;charset=utf-8",
"tags": {}
Expand Down Expand Up @@ -59,7 +59,7 @@
},
{
"key": "pratik-top-secret",
"value": "{\"uri\":\"https://prsangli-appc-keyvault.vault.azure.net/secrets/appc-keyvault-secret/977e940850eb42628b7719a7431f6c27\"}",
"value": "{\"uri\": \"https://prsangli-appc-keyvault.vault.azure.net/secrets/appc-keyvault-secret/977e940850eb42628b7719a7431f6c27\"}",
"label": null,
"content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"tags": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
{
"key": "pratik-top-secret",
"value": "{\"uri\":\"https://prsangli-appc-keyvault.vault.azure.net/secrets/appc-keyvault-secret/977e940850eb42628b7719a7431f6c27\"}",
"value": "{\"uri\": \"https://prsangli-appc-keyvault.vault.azure.net/secrets/appc-keyvault-secret/977e940850eb42628b7719a7431f6c27\"}",
"label": null,
"content_type": "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8",
"tags": {}
Expand Down
Loading

0 comments on commit 570a354

Please sign in to comment.