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] Stop overwriting KeyVault reference content type during import #18602

Merged
merged 2 commits into from
Jun 26, 2021
Merged
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 @@ -334,7 +334,7 @@ def __read_kv_from_config_store(azconfig_client,

if kv.content_type and kv.value:
# resolve key vault reference
if keyvault_client and kv.content_type == KeyVaultConstants.KEYVAULT_CONTENT_TYPE:
if keyvault_client and __is_key_vault_ref(kv):
__resolve_secret(keyvault_client, kv)

# trim unwanted fields from kv object instead of leaving them as null.
Expand Down Expand Up @@ -369,8 +369,8 @@ def __write_kv_and_features_to_config_store(azconfig_client,
if not preserve_labels:
set_kv.label = label

# Don't overwrite the content type of feature flags
if content_type and not __is_feature_flag(set_kv):
# Don't overwrite the content type of feature flags or key vault references
if content_type and not __is_feature_flag(set_kv) and not __is_key_vault_ref(set_kv):
set_kv.content_type = content_type

try:
Expand All @@ -389,6 +389,10 @@ def __is_feature_flag(kv):
return False


def __is_key_vault_ref(kv):
return kv and kv.content_type and kv.content_type.lower() == KeyVaultConstants.KEYVAULT_CONTENT_TYPE


def __discard_features_from_retrieved_kv(src_kvs):
try:
src_kvs[:] = [kv for kv in src_kvs if not __is_feature_flag(kv)]
Expand Down Expand Up @@ -467,7 +471,7 @@ def __write_kv_to_app_service(cmd, key_values, appservice_account):
name = kv.key
value = kv.value
# If its a KeyVault ref, convert the format to AppService KeyVault ref format
if kv.content_type and kv.content_type.lower() == KeyVaultConstants.KEYVAULT_CONTENT_TYPE:
if __is_key_vault_ref(kv):
try:
secret_uri = json.loads(value).get("uri")
if secret_uri:
Expand Down