From ae369fe7a895107cbfbf1ce77f0b998fce02d59c Mon Sep 17 00:00:00 2001 From: Avani Gupta Date: Tue, 7 Jan 2020 13:13:46 -0800 Subject: [PATCH] resolving comments --- .../azure/cli/command_modules/appconfig/_help.py | 12 ++---------- .../cli/command_modules/appconfig/_params.py | 10 +++++----- .../cli/command_modules/appconfig/keyvalue.py | 15 ++++++++------- .../tests/latest/export_features_prop.json | 2 +- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/appconfig/_help.py b/src/azure-cli/azure/cli/command_modules/appconfig/_help.py index ba4c9dc2219..5b53c357aaf 100644 --- a/src/azure-cli/azure/cli/command_modules/appconfig/_help.py +++ b/src/azure-cli/azure/cli/command_modules/appconfig/_help.py @@ -70,8 +70,6 @@ examples: - name: Export all keys and feature flags with label test to a json file. text: az appconfig kv export -n MyAppConfiguration --label test -d file --path D:/abc.json --format json - - name: Export all keys and feature flags with null label to another App Configuration. - text: az appconfig kv export -n MyAppConfiguration -d appconfig --dest-name AnotherAppConfiguration - name: Export all keys with null label to an App Service application. text: az appconfig kv export -n MyAppConfiguration -d appservice --appservice-account MyAppService - name: Export all keys with label test excluding feature flags to a json file. @@ -80,8 +78,6 @@ text: az appconfig kv export -n MyAppConfiguration -d appconfig --dest-name AnotherAppConfiguration --key * --label * --preserve-labels - name: Export all keys and feature flags with all labels to another App Configuration and overwrite destination labels. text: az appconfig kv export -n MyAppConfiguration -d appconfig --dest-name AnotherAppConfiguration --key * --label * --dest-label ExportedKeys - - name: Export all keys and feature flags with all labels to another App Configuration and assign null label in destination AppConfig. - text: az appconfig kv export -n MyAppConfiguration -d appconfig --dest-name AnotherAppConfiguration --key * --label * """ helps['appconfig kv import'] = """ @@ -90,18 +86,14 @@ examples: - name: Import all keys and feature flags from a file and apply test label. text: az appconfig kv import -n MyAppConfiguration --label test -s file --path D:/abc.json --format json - - name: Import all keys and feature flags with null label and apply null label from an App Configuration. - text: az appconfig kv import -n MyAppConfiguration -s appconfig --src-name AnotherAppConfiguration + - name: Import all keys and feature flags with null label and apply new label from an App Configuration. + text: az appconfig kv import -n MyAppConfiguration -s appconfig --src-name AnotherAppConfiguration --label ImportedKeys - name: Import all keys and apply null label from an App Service appliaction. text: az appconfig kv import -n MyAppConfiguration -s appservice --appservice-account MyAppService - name: Import all keys with label test and apply test2 label excluding feature flags from an App Configuration. text: az appconfig kv import -n MyAppConfiguration -s appconfig --src-label test --label test2 --src-name AnotherAppConfiguration --skip-features - name: Import all keys and feature flags with all labels to another App Configuration. text: az appconfig kv import -n MyAppConfiguration -s appconfig --src-name AnotherAppConfiguration --src-key * --src-label * --preserve-labels - - name: Import all keys and feature flags with all labels to another App Configuration and overwrite labels. - text: az appconfig kv import -n MyAppConfiguration -s appconfig --src-name AnotherAppConfiguration --src-key * --src-label * --label ImportedKeys - - name: Import all keys and feature flags with all labels to another App Configuration and assign null label. - text: az appconfig kv import -n MyAppConfiguration -s appconfig --src-name AnotherAppConfiguration --src-key * --src-label * """ helps['appconfig kv list'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/appconfig/_params.py b/src/azure-cli/azure/cli/command_modules/appconfig/_params.py index b2577c9ceca..fbae6e94cb9 100644 --- a/src/azure-cli/azure/cli/command_modules/appconfig/_params.py +++ b/src/azure-cli/azure/cli/command_modules/appconfig/_params.py @@ -75,7 +75,7 @@ def load_arguments(self, _): c.argument('id_', options_list=['--id'], help='Id of the key to be regenerated. Can be found using az appconfig credential list command.') with self.argument_context('appconfig kv import') as c: - c.argument('label', help="Imported KVs and feature flags will be assigned with this label. If omitted, for file and appservice source, will assign null label by default. For AppConfig source, if neither --label nor --preserve-labels is specified, will assign null label by default. If there are duplicate keys in source AppConfig, only the last key will be imported with this label.") + c.argument('label', help="Imported KVs and feature flags will be assigned with this label. If no label specified, will assign null label.") c.argument('prefix', help="This prefix will be appended to the front of imported keys. Prefix will be ignored for feature flags.") c.argument('source', options_list=['--source', '-s'], arg_type=get_enum_type(['file', 'appconfig', 'appservice']), validator=validate_import, help="The source of importing. Note that importing feature flags from appservice is not supported.") c.argument('yes', help="Do not prompt for preview.") @@ -92,8 +92,8 @@ def load_arguments(self, _): c.argument('src_name', help='The name of the source App Configuration.') c.argument('src_connection_string', validator=validate_connection_string, help="Combination of access key and endpoint of the source store.") c.argument('src_key', help='If no key specified, import all keys by default. Support star sign as filters, for instance abc* means keys with abc as prefix. Similarly, *abc and *abc* are also supported. Key filtering not applicable for feature flags. By default, all feature flags with specified label will be imported.') - c.argument('src_label', help="Only keys with this label in source AppConfig will be imported. If no src-label specified, import keys with null label by default. Support star sign as filters, for instance * means all labels, abc* means labels with abc as prefix. Similarly, *abc and *abc* are also supported.") - c.argument('preserve_labels', arg_type=get_three_state_flag(), help="Original labels from source AppConfig will be preserved for all KVs. This argument should only be specified when --label is NOT provided.") + c.argument('src_label', help="Only keys with this label in source AppConfig will be imported. If no value specified, import keys with null label by default. Support star sign as filters, for instance * means all labels, abc* means labels with abc as prefix. Similarly, *abc and *abc* are also supported.") + c.argument('preserve_labels', arg_type=get_three_state_flag(), help="Flag to preserve labels from source AppConfig. This argument should NOT be specified along with --label.") with self.argument_context('appconfig kv import', arg_group='AppService') as c: c.argument('appservice_account', validator=validate_appservice_name_or_id, help='ARM ID for AppService OR the name of the AppService, assuming it is in the same subscription and resource group as the App Configuration. Required for AppService arguments') @@ -117,8 +117,8 @@ def load_arguments(self, _): with self.argument_context('appconfig kv export', arg_group='AppConfig') as c: c.argument('dest_name', help='The name of the destination App Configuration.') c.argument('dest_connection_string', validator=validate_connection_string, help="Combination of access key and endpoint of the destination store.") - c.argument('dest_label', help="Exported KVs will be labeled with this destination label. If neither --dest-label nor --preserve-labels is specified, will assign null label. If there are duplicate keys in source AppConfig, only the last key will be exported with dest-label.") - c.argument('preserve_labels', arg_type=get_three_state_flag(), help="Original labels from source AppConfig will be preserved for all KVs. This argument should only be specified when --dest-label is NOT provided.") + c.argument('dest_label', help="Exported KVs will be labeled with this destination label. If neither --dest-label nor --preserve-labels is specified, will assign null label.") + c.argument('preserve_labels', arg_type=get_three_state_flag(), help="Flag to preserve labels from source AppConfig. This argument should NOT be specified along with --dest-label.") with self.argument_context('appconfig kv export', arg_group='AppService') as c: c.argument('appservice_account', validator=validate_appservice_name_or_id, help='ARM ID for AppService OR the name of the AppService, assuming it is in the same subscription and resource group as the App Configuration. Required for AppService arguments') diff --git a/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py b/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py index 71ca53b1ff6..a1c28557495 100644 --- a/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py +++ b/src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py @@ -161,13 +161,14 @@ def export_config(cmd, format_ = format_.lower() if format_ else None naming_convention = naming_convention.lower() - if destination == 'appconfig' and dest_label is not None and preserve_labels: - raise CLIError("Export failed! Please provide only one of these arguments: 'dest-label' or 'preserve-labels'. See 'az appconfig kv export -h' for examples.") - if destination == 'appconfig' and preserve_labels: - # We need dest_label to be the same as label for preview later. - # This will have no effect on label while writing to config store - # as we check preserve_labels again before labelling KVs. - dest_label = label + if destination == 'appconfig': + if dest_label is not None and preserve_labels: + raise CLIError("Export failed! Please provide only one of these arguments: 'dest-label' or 'preserve-labels'. See 'az appconfig kv export -h' for examples.") + if preserve_labels: + # We need dest_label to be the same as label for preview later. + # This will have no effect on label while writing to config store + # as we check preserve_labels again before labelling KVs. + dest_label = label # fetch key values from user's configstore src_kvs = __read_kv_from_config_store( diff --git a/src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/export_features_prop.json b/src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/export_features_prop.json index 525657e4503..5def2f0e99f 100644 --- a/src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/export_features_prop.json +++ b/src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/export_features_prop.json @@ -1,4 +1,4 @@ -#Mon Dec 30 11:27:28 Pacific Standard Time 2019 +#Tue Jan 07 13:12:22 Pacific Standard Time 2020 Color=Red Region=West US feature-management.FalseFeature=false