Skip to content

Commit d4e9490

Browse files
AllyWLi Wang
andauthored
add prop value, norm type value and ignore add type (#418)
* add prop value, norm type value and ignore add type --------- Co-authored-by: Li Wang <liwang3@microsoft.com>
1 parent 64f4b0f commit d4e9490

13 files changed

Lines changed: 59 additions & 107 deletions

File tree

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
33
Release History
44
===============
5+
0.1.59
6+
++++++
7+
* `azdev command-change meta-export`: Normalize basic cmd types: str, bool, int, float
8+
59
0.1.58
610
++++++
711
* Fix cmdcov issue(#417): Any name of a parameter has been tested, the parameter should be considered as passing the parameter test coverage.

azdev/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# license information.
55
# -----------------------------------------------------------------------------
66

7-
__VERSION__ = '0.1.58'
7+
__VERSION__ = '0.1.59'

azdev/operations/command_change/custom.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,27 @@ def process_arg_type(argument_settings, para):
6767
para["type"] = raw_type if raw_type in ["str", "int", "float", "bool", "file_type"] else "custom_type"
6868

6969

70+
def normalize_para_types(para):
71+
type_string_opts = ["string", "str", "aazstrarg",
72+
"aazresourcelocationarg", "aazresourcegroupnamearg", "aazresourceidarg",
73+
"aazpaginationtokenarg", "aazfilearg"]
74+
75+
type_int_opts = ["int", "aazintarg", "aazpaginationlimitarg"]
76+
type_float_opts = ["float", "aazfloatarg"]
77+
type_bool_opts = ["boolean", "bool", "aazboolarg", "aazgenericupdateforcestringarg"]
78+
79+
def normalize_para_type(type_opts, value):
80+
if para.get("type", None) and para["type"].lower() in type_opts:
81+
para["type"] = value
82+
if para.get("aaz_type", None) and para["aaz_type"].lower() in type_opts:
83+
para["aaz_type"] = value
84+
85+
normalize_para_type(type_string_opts, "string")
86+
normalize_para_type(type_int_opts, "int")
87+
normalize_para_type(type_float_opts, "float")
88+
normalize_para_type(type_bool_opts, "bool")
89+
90+
7091
def gen_command_meta(command_info, with_help=False, with_example=False):
7192
stored_property_when_exist = ["confirmation", "supports_no_wait", "is_preview"]
7293
command_meta = {
@@ -118,6 +139,7 @@ def gen_command_meta(command_info, with_help=False, with_example=False):
118139
para["desc"] = settings["help"]
119140
if command_info["is_aaz"] and command_info["az_arguments_schema"]:
120141
process_aaz_argument(command_info["az_arguments_schema"], settings, para)
142+
normalize_para_types(para)
121143
parameters.append(para)
122144
command_meta["parameters"] = parameters
123145
return command_meta

azdev/utilities/__init__.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
get_azure_config_dir,
1010
get_azdev_config,
1111
get_azdev_config_dir,
12-
get_change_rule_template,
13-
get_change_suggest_template
1412
)
1513
from .command import (
1614
call,
@@ -20,18 +18,6 @@
2018
CommandError
2119
)
2220
from .const import (
23-
BREAKING_CHANE_RULE_LINK_URL_PREFIX,
24-
BREAKING_CHANE_RULE_LINK_URL_SUFFIX,
25-
CMD_PROPERTY_ADD_BREAK_LIST,
26-
CMD_PROPERTY_REMOVE_BREAK_LIST,
27-
CMD_PROPERTY_UPDATE_BREAK_LIST,
28-
CMD_PROPERTY_IGNORED_LIST,
29-
PARA_PROPERTY_ADD_BREAK_LIST,
30-
PARA_PROPERTY_REMOVE_BREAK_LIST,
31-
PARA_PROPERTY_UPDATE_BREAK_LIST,
32-
PARA_NAME_IGNORED_LIST,
33-
PARA_PROPERTY_IGNORED_LIST,
34-
PARA_VALUE_IGNORED_LIST,
3521
COMMAND_MODULE_PREFIX,
3622
EXTENSION_PREFIX,
3723
IS_WINDOWS,
@@ -73,18 +59,6 @@
7359
__all__ = [
7460
'COMMAND_MODULE_PREFIX',
7561
'EXTENSION_PREFIX',
76-
'BREAKING_CHANE_RULE_LINK_URL_PREFIX',
77-
'BREAKING_CHANE_RULE_LINK_URL_SUFFIX',
78-
'CMD_PROPERTY_ADD_BREAK_LIST',
79-
'CMD_PROPERTY_REMOVE_BREAK_LIST',
80-
'CMD_PROPERTY_UPDATE_BREAK_LIST',
81-
'CMD_PROPERTY_IGNORED_LIST',
82-
'PARA_PROPERTY_ADD_BREAK_LIST',
83-
'PARA_PROPERTY_REMOVE_BREAK_LIST',
84-
'PARA_PROPERTY_UPDATE_BREAK_LIST',
85-
'PARA_NAME_IGNORED_LIST',
86-
'PARA_PROPERTY_IGNORED_LIST',
87-
'PARA_VALUE_IGNORED_LIST',
8862
'display',
8963
'output',
9064
'heading',
@@ -102,8 +76,6 @@
10276
'get_azure_config',
10377
'get_azdev_config_dir',
10478
'get_azdev_config',
105-
'get_change_rule_template',
106-
'get_change_suggest_template',
10779
'ENV_VAR_TEST_MODULES',
10880
'ENV_VAR_TEST_LIVE',
10981
'ENV_VAR_VIRTUAL_ENV',

azdev/utilities/config.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os
88

99
from knack.config import CLIConfig
10-
from .const import CHANGE_RULE_MESSAGE_MAPPING, CHANGE_SUGGEST_MESSAGE_MAPPING
1110

1211

1312
def get_azdev_config():
@@ -32,13 +31,3 @@ def get_azdev_config_dir():
3231
def get_azure_config_dir():
3332
""" Returns the user's Azure directory. """
3433
return os.getenv('AZURE_CONFIG_DIR', None) or os.path.expanduser(os.path.join('~', '.azure'))
35-
36-
37-
def get_change_rule_template(rule_id="1000"):
38-
""" Return the rule message template"""
39-
return CHANGE_RULE_MESSAGE_MAPPING.get(rule_id, "Non applicable")
40-
41-
42-
def get_change_suggest_template(rule_id="1000"):
43-
""" Return the change suggest message template"""
44-
return CHANGE_SUGGEST_MESSAGE_MAPPING.get(rule_id, "Non applicable")

azdev/utilities/const.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,3 @@
1414
ENV_VAR_TEST_MODULES = 'AZDEV_TEST_TESTS' # comma-separated list of modules to test
1515
ENV_VAR_VIRTUAL_ENV = ['VIRTUAL_ENV', 'CONDA_PREFIX'] # used by system to identify virtual environment
1616
ENV_VAR_TEST_LIVE = 'AZURE_TEST_RUN_LIVE' # denotes that tests should be run live instead of played back
17-
18-
BREAKING_CHANE_RULE_LINK_URL_PREFIX = "https://github.com/Azure/azure-cli/blob/dev/doc/breaking_change_rules/"
19-
BREAKING_CHANE_RULE_LINK_URL_SUFFIX = ".md"
20-
21-
CMD_PROPERTY_REMOVE_BREAK_LIST = []
22-
CMD_PROPERTY_ADD_BREAK_LIST = ["confirmation"]
23-
CMD_PROPERTY_UPDATE_BREAK_LIST = []
24-
CMD_PROPERTY_IGNORED_LIST = ["is_aaz", "supports_no_wait"]
25-
26-
PARA_PROPERTY_REMOVE_BREAK_LIST = ["options", "id_part", "nargs"]
27-
PARA_PROPERTY_ADD_BREAK_LIST = ["required", "choices", "type"]
28-
PARA_PROPERTY_UPDATE_BREAK_LIST = ["default", "aaz_default", "type"]
29-
PARA_NAME_IGNORED_LIST = ["force_string"]
30-
PARA_PROPERTY_IGNORED_LIST = []
31-
PARA_VALUE_IGNORED_LIST = ["generic_update_set", "generic_update_add", "generic_update_remove",
32-
"generic_update_force_string"]
33-
34-
CHANGE_RULE_MESSAGE_MAPPING = {
35-
"1000": "default Message",
36-
"1001": "cmd `{0}` added",
37-
"1002": "cmd `{0}` removed",
38-
"1003": "cmd `{0}` added property `{1}`",
39-
"1004": "cmd `{0}` removed property `{1}`",
40-
"1005": "cmd `{0}` updated property `{1}` from `{2}` to `{3}`",
41-
"1006": "cmd `{0}` added parameter `{1}`",
42-
"1007": "cmd `{0}` removed parameter `{1}`",
43-
"1008": "cmd `{0}` update parameter `{1}`: added property `{2}`",
44-
"1009": "cmd `{0}` update parameter `{1}`: removed property `{2}`",
45-
"1010": "cmd `{0}` update parameter `{1}`: updated property `{2}` from `{3}` to `{4}`",
46-
"1011": "sub group `{0}` added",
47-
"1012": "sub group `{0}` removed",
48-
}
49-
50-
CHANGE_SUGGEST_MESSAGE_MAPPING = {
51-
"1000": "default Message",
52-
"1001": "please confirm cmd `{0}` added",
53-
"1002": "please confirm cmd `{0}` removed",
54-
"1003": "please remove property `{0}` for cmd `{1}`",
55-
"1004": "please add back property `{0}` for cmd `{1}`",
56-
"1005": "please change property `{0}` from `{1}` to `{2}` for cmd `{3}`",
57-
"1006": "please remove parameter `{0}` for cmd `{1}`",
58-
"1007": "please add back parameter `{0}` for cmd `{1}`",
59-
"1008": "please remove property `{0}` for parameter `{1}` for cmd `{2}`",
60-
"1009": "please add back property `{0}` for parameter {1}` for cmd `{2}`",
61-
"1010": "please change property `{0}` from `{1}` to `{2}` for parameter `{3}` of cmd `{4}`",
62-
"1011": "please confirm sub group `{0}` added",
63-
"1012": "please confirm sub group `{0}` removed",
64-
}

azure-cli-diff-tool/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
33
Release History
44
===============
5+
0.0.3
6+
++++++
7+
* Add prop value for parameter add/remove property
8+
* Remove type add break justification
9+
510
0.0.2
611
++++++
712
* Change time consuming into info log level

azure-cli-diff-tool/azure_cli_diff_tool/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
extract_module_name_from_meta_file, export_meta_changes_to_csv, export_meta_changes_to_json, \
1919
export_meta_changes_to_dict
2020

21-
__VERSION__ = '0.0.2'
21+
__VERSION__ = '0.0.3'
2222

2323
logger = logging.getLogger(__name__)
2424

azure-cli-diff-tool/azure_cli_diff_tool/_const.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
CMD_PROPERTY_IGNORED_LIST = ["is_aaz", "supports_no_wait"]
2424

2525
PARA_PROPERTY_REMOVE_BREAK_LIST = ["options", "id_part", "nargs"]
26-
PARA_PROPERTY_ADD_BREAK_LIST = ["required", "choices", "type"]
27-
PARA_PROPERTY_UPDATE_BREAK_LIST = ["default", "aaz_default", "type"]
26+
PARA_PROPERTY_ADD_BREAK_LIST = ["required", "choices"]
27+
PARA_PROPERTY_UPDATE_BREAK_LIST = ["default", "aaz_default", "type", "aaz_type"]
2828
PARA_NAME_IGNORED_LIST = ["force_string"]
2929
PARA_PROPERTY_IGNORED_LIST = []
3030
PARA_VALUE_IGNORED_LIST = ["generic_update_set", "generic_update_add", "generic_update_remove",
@@ -42,8 +42,8 @@
4242
"1005": "cmd `{0}` updated property `{1}` from `{2}` to `{3}`",
4343
"1006": "cmd `{0}` added parameter `{1}`",
4444
"1007": "cmd `{0}` removed parameter `{1}`",
45-
"1008": "cmd `{0}` update parameter `{1}`: added property `{2}`",
46-
"1009": "cmd `{0}` update parameter `{1}`: removed property `{2}`",
45+
"1008": "cmd `{0}` update parameter `{1}`: added property `{2}={3}`",
46+
"1009": "cmd `{0}` update parameter `{1}`: removed property `{2}={3}`",
4747
"1010": "cmd `{0}` update parameter `{1}`: updated property `{2}` from `{3}` to `{4}`",
4848
"1011": "sub group `{0}` added",
4949
"1012": "sub group `{0}` removed",
@@ -58,8 +58,8 @@
5858
"1005": "please change property `{0}` from `{1}` to `{2}` for cmd `{3}`",
5959
"1006": "please remove parameter `{0}` for cmd `{1}`",
6060
"1007": "please add back parameter `{0}` for cmd `{1}`",
61-
"1008": "please remove property `{0}` for parameter `{1}` for cmd `{2}`",
62-
"1009": "please add back property `{0}` for parameter {1}` for cmd `{2}`",
61+
"1008": "please remove property `{0}={1}` for parameter `{2}` of cmd `{3}`",
62+
"1009": "please add back property `{0}={1}` for parameter `{2}` of cmd `{3}`",
6363
"1010": "please change property `{0}` from `{1}` to `{2}` for parameter `{3}` of cmd `{4}`",
6464
"1011": "please confirm sub group `{0}` added",
6565
"1012": "please confirm sub group `{0}` removed",

azure-cli-diff-tool/azure_cli_diff_tool/meta_change.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,21 @@ def __init__(self, cmd_name, para_name, is_break=False):
178178

179179
class ParaPropAdd(MetaChange):
180180

181-
def __init__(self, cmd_name, para_name, para_property, is_break=False):
181+
def __init__(self, cmd_name, para_name, para_property, para_prop_value, is_break=False):
182182
if not cmd_name or not para_name or not para_property:
183183
raise Exception("cmd name, parameter name and parameter property needed")
184184
self.rule_id = "1008"
185185
self.is_ignore = False
186186
self.cmd_name = cmd_name
187187
self.para_name = para_name
188188
self.para_prop = para_property
189+
self.para_prop_value = para_prop_value
189190
self.is_break = is_break
190191

191192
self.rule_message = get_change_rule_template(self.rule_id).format(self.cmd_name, self.para_name,
192-
self.para_prop)
193+
self.para_prop, self.para_prop_value)
193194
self.suggest_message = get_change_suggest_template(self.rule_id).format(self.para_prop,
195+
self.para_prop_value,
194196
self.para_name,
195197
self.cmd_name) if self.is_break else ""
196198
if para_property in PARA_PROPERTY_IGNORED_LIST or para_name in PARA_NAME_IGNORED_LIST:
@@ -200,19 +202,21 @@ def __init__(self, cmd_name, para_name, para_property, is_break=False):
200202

201203
class ParaPropRemove(MetaChange):
202204

203-
def __init__(self, cmd_name, para_name, para_property, is_break=False):
205+
def __init__(self, cmd_name, para_name, para_property, para_prop_value, is_break=False):
204206
if not cmd_name or not para_name or not para_property:
205207
raise Exception("cmd name, parameter name and parameter property needed")
206208
self.rule_id = "1009"
207209
self.is_ignore = False
208210
self.cmd_name = cmd_name
209211
self.para_name = para_name
210212
self.para_prop = para_property
213+
self.para_prop_value = para_prop_value
211214
self.is_break = is_break
212215

213216
self.rule_message = get_change_rule_template(self.rule_id).format(self.cmd_name, self.para_name,
214-
self.para_prop)
217+
self.para_prop, self.para_prop_value)
215218
self.suggest_message = get_change_suggest_template(self.rule_id).format(self.para_prop,
219+
self.para_prop_value,
216220
self.para_name,
217221
self.cmd_name) if self.is_break else ""
218222
if para_property in PARA_PROPERTY_IGNORED_LIST or para_name in PARA_NAME_IGNORED_LIST:

0 commit comments

Comments
 (0)