Skip to content
Merged
Changes from 2 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 @@ -106,7 +106,6 @@ def validate_import_key(key):
else:
logger.warning("Ignoring invalid key ''. Key cannot be empty.")
return False

return True


Expand Down Expand Up @@ -1027,11 +1026,11 @@ def __import_kvset_from_file(client, path, yes):
if KVSetConstants.KVSETRootElementName not in new_kvset:
raise FileOperationError("file '{0}' is not in a valid '{1}' format.".format(path, ImportExportProfiles.KVSET))

kvset_to_import = [ConfigurationSetting(key=kv['key'],
label=kv['label'],
content_type=kv['content_type'],
value=kv['value'],
tags=kv['tags'])
kvset_to_import = [ConfigurationSetting(key=kv['key'] if 'key' in kv else None,
label=kv['label'] if 'label' in kv else None,
content_type=kv['content_type'] if 'content_type' in kv else None,
value=kv['value'] if 'value' in kv else None,
tags=kv['tags'] if 'tags' in kv else None)
for kv in new_kvset[KVSetConstants.KVSETRootElementName]]

if not yes:
Expand Down Expand Up @@ -1064,8 +1063,9 @@ def __import_kvset_from_file(client, path, yes):
continue
elif not validate_import_key(config_setting.key):
continue

__validate_import_tags(config_setting)
# All validations successful

__write_configuration_setting_to_config_store(client, config_setting)


Expand Down Expand Up @@ -1103,6 +1103,14 @@ def __validate_import_feature_flag(kv):
return False


def __validate_import_tags(kv):
if kv.tags:
for tag_key, tag_value in kv.tags.items():
if not isinstance(tag_value, str):
logger.warning("The value for the tag '{%s}' for key '{%s}' is not a string. It will be converted to a string.", tag_key, kv.key)
return


def __write_configuration_setting_to_config_store(azconfig_client, configuration_setting):
try:
azconfig_client.set_configuration_setting(configuration_setting)
Expand Down