azure-cli-diff-tool 0.0.5__tar.gz → 0.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/PKG-INFO +9 -1
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/__init__.py +6 -4
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/_const.py +24 -6
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/meta_change.py +80 -1
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/meta_change_detect.py +153 -79
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/utils.py +42 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/PKG-INFO +9 -1
- azure_cli_diff_tool-0.0.7/tests/test_break_change.py +179 -0
- azure-cli-diff-tool-0.0.5/tests/test_break_change.py +0 -88
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/README.rst +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/data/blob_config.ini +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/data/meta_change_whitelist.txt +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/SOURCES.txt +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/dependency_links.txt +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/requires.txt +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/top_level.txt +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/setup.cfg +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/setup.py +0 -0
- {azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: azure-cli-diff-tool
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.7
|
|
4
4
|
Summary: A tool for cli metadata management
|
|
5
5
|
Author: Microsoft Corporation
|
|
6
6
|
Author-email: azpycli@microsoft.com
|
|
@@ -98,6 +98,14 @@ License
|
|
|
98
98
|
|
|
99
99
|
Release History
|
|
100
100
|
===============
|
|
101
|
+
0.0.7
|
|
102
|
+
++++++
|
|
103
|
+
* Remove unnecessary debug logs for meta comparison
|
|
104
|
+
|
|
105
|
+
0.0.6
|
|
106
|
+
++++++
|
|
107
|
+
* Add diff support for deprecate_info in subgroup, cmd, parameters and options
|
|
108
|
+
|
|
101
109
|
0.0.5
|
|
102
110
|
++++++
|
|
103
111
|
* Add `DiffLevel` to meta comparison
|
|
@@ -16,9 +16,9 @@ from deepdiff import DeepDiff
|
|
|
16
16
|
from .meta_change_detect import MetaChangeDetect
|
|
17
17
|
from .utils import get_blob_config, load_blob_config_file, get_target_version_modules, get_target_version_module, \
|
|
18
18
|
extract_module_name_from_meta_file, export_meta_changes_to_csv, export_meta_changes_to_json, \
|
|
19
|
-
export_meta_changes_to_dict
|
|
19
|
+
export_meta_changes_to_dict, expand_deprecate_obj
|
|
20
20
|
|
|
21
|
-
__VERSION__ = '0.0.
|
|
21
|
+
__VERSION__ = '0.0.7'
|
|
22
22
|
|
|
23
23
|
logger = logging.getLogger(__name__)
|
|
24
24
|
|
|
@@ -61,7 +61,8 @@ def meta_diff(base_meta_file, diff_meta_file, only_break=False, output_type="tex
|
|
|
61
61
|
if command_tree_after.get("compat_version", None) \
|
|
62
62
|
and check_meta_tool_compatibility(command_tree_after["compat_version"]):
|
|
63
63
|
raise Exception("Please update your azure cli diff tool")
|
|
64
|
-
|
|
64
|
+
expand_deprecate_obj(command_tree_before)
|
|
65
|
+
expand_deprecate_obj(command_tree_after)
|
|
65
66
|
diff = DeepDiff(command_tree_before, command_tree_after)
|
|
66
67
|
if not diff:
|
|
67
68
|
print(f"No meta diffs from {diff_meta_file} to {base_meta_file}")
|
|
@@ -116,7 +117,8 @@ def version_diff(base_version, diff_version, only_break=False, version_diff_file
|
|
|
116
117
|
if command_tree_after.get("compat_version", None) \
|
|
117
118
|
and check_meta_tool_compatibility(command_tree_after["compat_version"]):
|
|
118
119
|
raise Exception("Please update your azure cli diff tool")
|
|
119
|
-
|
|
120
|
+
expand_deprecate_obj(command_tree_before)
|
|
121
|
+
expand_deprecate_obj(command_tree_after)
|
|
120
122
|
diff = DeepDiff(command_tree_before, command_tree_after)
|
|
121
123
|
if not diff:
|
|
122
124
|
print(f"No meta diffs from version: {diff_version}/{base_meta_file} for module: {module_name}")
|
|
@@ -19,25 +19,37 @@ BREAKING_CHANE_RULE_LINK_URL_SUFFIX = ".md"
|
|
|
19
19
|
|
|
20
20
|
CMD_REMOVE_SUFFIX_WARN_LIST = ["wait"]
|
|
21
21
|
|
|
22
|
+
SUBGROUP_PROPERTY_REMOVE_BREAK_LIST = []
|
|
23
|
+
SUBGROUP_PROPERTY_REMOVE_WARN_LIST = ["deprecate_info_redirect"]
|
|
24
|
+
|
|
25
|
+
SUBGROUP_PROPERTY_ADD_BREAK_LIST = []
|
|
26
|
+
SUBGROUP_PROPERTY_ADD_WARN_LIST = ["deprecate_info_hide", "deprecate_info_expiration"]
|
|
27
|
+
|
|
28
|
+
SUBGROUP_PROPERTY_UPDATE_BREAK_LIST = []
|
|
29
|
+
SUBGROUP_PROPERTY_UPDATE_WARN_LIST = ["deprecate_info_expiration"]
|
|
30
|
+
|
|
31
|
+
SUBGROUP_PROPERTY_IGNORED_LIST = []
|
|
32
|
+
|
|
22
33
|
CMD_PROPERTY_REMOVE_BREAK_LIST = []
|
|
23
|
-
CMD_PROPERTY_REMOVE_WARN_LIST = []
|
|
34
|
+
CMD_PROPERTY_REMOVE_WARN_LIST = ["deprecate_info_redirect"]
|
|
24
35
|
|
|
25
36
|
CMD_PROPERTY_ADD_BREAK_LIST = ["confirmation"]
|
|
26
|
-
CMD_PROPERTY_ADD_WARN_LIST = []
|
|
37
|
+
CMD_PROPERTY_ADD_WARN_LIST = ["deprecate_info_hide", "deprecate_info_expiration"]
|
|
27
38
|
|
|
28
39
|
CMD_PROPERTY_UPDATE_BREAK_LIST = []
|
|
29
|
-
CMD_PROPERTY_UPDATE_WARN_LIST = []
|
|
40
|
+
CMD_PROPERTY_UPDATE_WARN_LIST = ["deprecate_info_expiration", "deprecate_info_redirect"]
|
|
30
41
|
|
|
31
42
|
CMD_PROPERTY_IGNORED_LIST = ["is_aaz", "supports_no_wait"]
|
|
32
43
|
|
|
33
44
|
PARA_PROPERTY_REMOVE_BREAK_LIST = ["options"]
|
|
34
|
-
PARA_PROPERTY_REMOVE_WARN_LIST = ["id_part", "nargs"]
|
|
45
|
+
PARA_PROPERTY_REMOVE_WARN_LIST = ["id_part", "nargs", "deprecate_info_redirect"]
|
|
35
46
|
|
|
36
47
|
PARA_PROPERTY_ADD_BREAK_LIST = ["required"]
|
|
37
|
-
PARA_PROPERTY_ADD_WARN_LIST = ["choices"]
|
|
48
|
+
PARA_PROPERTY_ADD_WARN_LIST = ["choices", "deprecate_info_expiration", "deprecate_info_hide", "options_deprecate_info"]
|
|
38
49
|
|
|
39
50
|
PARA_PROPERTY_UPDATE_BREAK_LIST = ["default", "aaz_default"]
|
|
40
|
-
PARA_PROPERTY_UPDATE_WARN_LIST = ["type", "aaz_type", "choices", "nargs"
|
|
51
|
+
PARA_PROPERTY_UPDATE_WARN_LIST = ["type", "aaz_type", "choices", "nargs",
|
|
52
|
+
"deprecate_info_expiration", "deprecate_info_redirect", "options_deprecate_info"]
|
|
41
53
|
|
|
42
54
|
PARA_NAME_IGNORED_LIST = ["force_string"]
|
|
43
55
|
PARA_PROPERTY_IGNORED_LIST = []
|
|
@@ -61,6 +73,9 @@ CHANGE_RULE_MESSAGE_MAPPING = {
|
|
|
61
73
|
"1010": "cmd `{0}` update parameter `{1}`: updated property `{2}` from `{3}` to `{4}`",
|
|
62
74
|
"1011": "sub group `{0}` added",
|
|
63
75
|
"1012": "sub group `{0}` removed",
|
|
76
|
+
"1013": "sub group `{0}` added property `{1}`",
|
|
77
|
+
"1014": "sub group `{0}` removed property `{1}`",
|
|
78
|
+
"1015": "sub group `{0}` updated property `{1}` from `{2}` to `{3}`",
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
CHANGE_SUGGEST_MESSAGE_MAPPING = {
|
|
@@ -77,5 +92,8 @@ CHANGE_SUGGEST_MESSAGE_MAPPING = {
|
|
|
77
92
|
"1010": "please change property `{0}` from `{1}` to `{2}` for parameter `{3}` of cmd `{4}`",
|
|
78
93
|
"1011": "please confirm sub group `{0}` added",
|
|
79
94
|
"1012": "please confirm sub group `{0}` removed",
|
|
95
|
+
"1013": "please remove property `{0}` for sub group `{1}`",
|
|
96
|
+
"1014": "please add back property `{0}` for sub group `{1}`",
|
|
97
|
+
"1015": "please change property `{0}` from `{1}` to `{2}` for sub group `{3}`",
|
|
80
98
|
}
|
|
81
99
|
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
from .utils import get_change_rule_template, get_change_suggest_template, DiffLevel
|
|
8
8
|
from ._const import BREAKING_CHANE_RULE_LINK_URL_PREFIX, BREAKING_CHANE_RULE_LINK_URL_SUFFIX, \
|
|
9
|
-
CMD_PROPERTY_IGNORED_LIST, PARA_NAME_IGNORED_LIST,
|
|
9
|
+
SUBGROUP_PROPERTY_IGNORED_LIST, CMD_PROPERTY_IGNORED_LIST, PARA_NAME_IGNORED_LIST, \
|
|
10
|
+
PARA_PROPERTY_IGNORED_LIST, PARA_VALUE_IGNORED_LIST
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class MetaChange:
|
|
@@ -58,6 +59,84 @@ class SubgroupRemove(MetaChange):
|
|
|
58
59
|
super().__init__(self.rule_id, is_break, diff_level, self.rule_message, self.suggest_message)
|
|
59
60
|
|
|
60
61
|
|
|
62
|
+
class SubgroupPropAdd(MetaChange):
|
|
63
|
+
def __init__(self, subgroup_name, subgroup_property, is_break=False, diff_level=DiffLevel.INFO):
|
|
64
|
+
if not subgroup_name or not subgroup_property:
|
|
65
|
+
raise Exception("sub group name needed")
|
|
66
|
+
self.rule_id = "1013"
|
|
67
|
+
self.is_ignore = False
|
|
68
|
+
self.subgroup_name = subgroup_name
|
|
69
|
+
self.subgroup_property = subgroup_property
|
|
70
|
+
self.is_break = is_break
|
|
71
|
+
self.diff_level = diff_level
|
|
72
|
+
self.rule_message = get_change_rule_template(self.rule_id).format(self.subgroup_name, self.subgroup_property)
|
|
73
|
+
self.suggest_message = get_change_suggest_template(self.rule_id).format(self.subgroup_property, self.subgroup_name) \
|
|
74
|
+
if self.is_break else ""
|
|
75
|
+
if subgroup_property in SUBGROUP_PROPERTY_IGNORED_LIST:
|
|
76
|
+
self.is_ignore = True
|
|
77
|
+
self.filter_key = [self.rule_id, self.subgroup_name, self.subgroup_property]
|
|
78
|
+
super().__init__(self.rule_id, is_break, diff_level, self.rule_message, self.suggest_message, self.is_ignore,
|
|
79
|
+
self.filter_key)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class SubgroupPropRemove(MetaChange):
|
|
83
|
+
def __init__(self, subgroup_name, subgroup_property, is_break=False, diff_level=DiffLevel.BREAK):
|
|
84
|
+
if not subgroup_name or not subgroup_property:
|
|
85
|
+
raise Exception("sub group name needed")
|
|
86
|
+
self.rule_id = "1014"
|
|
87
|
+
self.is_ignore = False
|
|
88
|
+
self.subgroup_name = subgroup_name
|
|
89
|
+
self.subgroup_property = subgroup_property
|
|
90
|
+
self.is_break = is_break
|
|
91
|
+
self.diff_level = diff_level
|
|
92
|
+
self.rule_message = get_change_rule_template(self.rule_id).format(self.subgroup_name, self.subgroup_property)
|
|
93
|
+
if self.is_break:
|
|
94
|
+
self.suggest_message = get_change_suggest_template(self.rule_id).format(self.subgroup_property,
|
|
95
|
+
self.subgroup_name)
|
|
96
|
+
else:
|
|
97
|
+
self.suggest_message = ""
|
|
98
|
+
if subgroup_property in CMD_PROPERTY_IGNORED_LIST:
|
|
99
|
+
self.is_ignore = True
|
|
100
|
+
self.filter_key = [self.rule_id, self.subgroup_name, self.subgroup_property]
|
|
101
|
+
super().__init__(self.rule_id, is_break, diff_level, self.rule_message, self.suggest_message,
|
|
102
|
+
self.is_ignore, self.filter_key)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class SubgroupPropUpdate(MetaChange):
|
|
106
|
+
|
|
107
|
+
def __init__(self, subgroup_name, subgroup_property, is_break=False, diff_level=DiffLevel.INFO,
|
|
108
|
+
old_value=None, new_value=None):
|
|
109
|
+
if not subgroup_name or not subgroup_property:
|
|
110
|
+
raise Exception("sub group name and sub group prop needed")
|
|
111
|
+
self.rule_id = "1015"
|
|
112
|
+
self.is_ignore = False
|
|
113
|
+
self.subgroup_name = subgroup_name
|
|
114
|
+
self.is_break = is_break
|
|
115
|
+
self.diff_level = diff_level
|
|
116
|
+
self.subgroup_prop_updated = subgroup_property
|
|
117
|
+
self.old_value = ""
|
|
118
|
+
self.new_value = ""
|
|
119
|
+
|
|
120
|
+
if old_value is not None:
|
|
121
|
+
self.old_value = old_value
|
|
122
|
+
if new_value is not None:
|
|
123
|
+
self.new_value = new_value
|
|
124
|
+
self.rule_message = get_change_rule_template(self.rule_id).format(self.subgroup_name,
|
|
125
|
+
self.subgroup_prop_updated,
|
|
126
|
+
self.old_value, self.new_value)
|
|
127
|
+
if self.is_break:
|
|
128
|
+
self.suggest_message = get_change_suggest_template(self.rule_id).format(self.subgroup_prop_updated,
|
|
129
|
+
self.new_value, self.old_value,
|
|
130
|
+
self.subgroup_name)
|
|
131
|
+
else:
|
|
132
|
+
self.suggest_message = ""
|
|
133
|
+
if subgroup_property in SUBGROUP_PROPERTY_IGNORED_LIST:
|
|
134
|
+
self.is_ignore = True
|
|
135
|
+
self.filter_key = [self.rule_id, self.subgroup_name, self.subgroup_prop_updated]
|
|
136
|
+
super().__init__(self.rule_id, is_break, diff_level, self.rule_message, self.suggest_message,
|
|
137
|
+
self.is_ignore, self.filter_key)
|
|
138
|
+
|
|
139
|
+
|
|
61
140
|
class CmdAdd(MetaChange):
|
|
62
141
|
def __init__(self, cmd_name, is_break=False, diff_level=DiffLevel.INFO):
|
|
63
142
|
if not cmd_name:
|
{azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/meta_change_detect.py
RENAMED
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
import logging
|
|
8
8
|
import os.path
|
|
9
9
|
|
|
10
|
-
from .utils import get_command_tree, ChangeType, extract_cmd_name, extract_subgroup_name,
|
|
10
|
+
from .utils import get_command_tree, ChangeType, extract_cmd_name, extract_subgroup_name, extract_subgroup_property, \
|
|
11
|
+
extract_subgroup_deprecate_property, extract_cmd_property, extract_cmd_deprecate_property, DiffLevel
|
|
11
12
|
from .meta_change import (CmdAdd, CmdRemove, CmdPropAdd, CmdPropRemove, CmdPropUpdate,
|
|
12
13
|
ParaAdd, ParaRemove, ParaPropAdd, ParaPropRemove, ParaPropUpdate,
|
|
13
|
-
SubgroupAdd, SubgroupRemove)
|
|
14
|
-
from ._const import (
|
|
14
|
+
SubgroupAdd, SubgroupRemove, SubgroupPropAdd, SubgroupPropRemove, SubgroupPropUpdate)
|
|
15
|
+
from ._const import (SUBGROUP_PROPERTY_ADD_BREAK_LIST, SUBGROUP_PROPERTY_ADD_WARN_LIST,
|
|
16
|
+
SUBGROUP_PROPERTY_REMOVE_BREAK_LIST, SUBGROUP_PROPERTY_REMOVE_WARN_LIST,
|
|
17
|
+
SUBGROUP_PROPERTY_UPDATE_BREAK_LIST, SUBGROUP_PROPERTY_UPDATE_WARN_LIST,
|
|
18
|
+
CMD_PROPERTY_ADD_BREAK_LIST, CMD_PROPERTY_ADD_WARN_LIST,
|
|
15
19
|
CMD_PROPERTY_REMOVE_BREAK_LIST, CMD_PROPERTY_REMOVE_WARN_LIST,
|
|
16
20
|
CMD_PROPERTY_UPDATE_BREAK_LIST, CMD_PROPERTY_UPDATE_WARN_LIST,
|
|
17
21
|
PARA_PROPERTY_REMOVE_BREAK_LIST, PARA_PROPERTY_REMOVE_WARN_LIST,
|
|
@@ -28,7 +32,10 @@ class MetaChangeDetect:
|
|
|
28
32
|
EXPORTED_META_PROPERTY = ["rule_id", "rule_link_url", "is_break", "diff_level",
|
|
29
33
|
"rule_message", "suggest_message", "cmd_name", "subgroup_name"]
|
|
30
34
|
CHECKED_PARA_PROPERTY = ["name", "options", "required", "choices", "id_part", "nargs", "default", "desc",
|
|
31
|
-
"aaz_type", "type", "aaz_default", "aaz_choices"
|
|
35
|
+
"aaz_type", "type", "aaz_default", "aaz_choices",
|
|
36
|
+
"deprecate_info_target", "deprecate_info_redirect", "deprecate_info_hide",
|
|
37
|
+
"deprecate_info_expiration",
|
|
38
|
+
"options_deprecate_info"]
|
|
32
39
|
|
|
33
40
|
def __init__(self, deep_diff=None, base_meta=None, diff_meta=None):
|
|
34
41
|
self.deep_diff = {}
|
|
@@ -74,6 +81,69 @@ class MetaChangeDetect:
|
|
|
74
81
|
def __log_cmd_with_parameter_change(self, cmd_name):
|
|
75
82
|
self.cmd_set_with_parameter_change.add(cmd_name)
|
|
76
83
|
|
|
84
|
+
def __process_subgroup_items(self, dict_key, subgroup_name, diff_type):
|
|
85
|
+
has_subgroup_key, subgroup_property = extract_subgroup_property(dict_key, subgroup_name)
|
|
86
|
+
if not has_subgroup_key:
|
|
87
|
+
if diff_type == ChangeType.REMOVE:
|
|
88
|
+
diff_obj = SubgroupRemove(subgroup_name)
|
|
89
|
+
else:
|
|
90
|
+
diff_obj = SubgroupAdd(subgroup_name)
|
|
91
|
+
self.diff_objs.append(diff_obj)
|
|
92
|
+
return
|
|
93
|
+
|
|
94
|
+
# deal with deprecate_info expanded key's add/remove/update
|
|
95
|
+
if diff_type == ChangeType.ADD:
|
|
96
|
+
if subgroup_property in SUBGROUP_PROPERTY_ADD_WARN_LIST:
|
|
97
|
+
diff_obj = SubgroupPropAdd(subgroup_name, subgroup_property, False, DiffLevel.WARN)
|
|
98
|
+
elif subgroup_property in SUBGROUP_PROPERTY_ADD_BREAK_LIST:
|
|
99
|
+
diff_obj = SubgroupPropAdd(subgroup_name, subgroup_property, True, DiffLevel.BREAK)
|
|
100
|
+
else:
|
|
101
|
+
diff_obj = SubgroupPropAdd(subgroup_name, subgroup_property, False, DiffLevel.INFO)
|
|
102
|
+
self.diff_objs.append(diff_obj)
|
|
103
|
+
else:
|
|
104
|
+
if subgroup_property in SUBGROUP_PROPERTY_REMOVE_WARN_LIST:
|
|
105
|
+
diff_obj = SubgroupPropRemove(subgroup_name, subgroup_property, False, DiffLevel.WARN)
|
|
106
|
+
elif subgroup_property in SUBGROUP_PROPERTY_REMOVE_BREAK_LIST:
|
|
107
|
+
diff_obj = SubgroupPropRemove(subgroup_name, subgroup_property, True, DiffLevel.BREAK)
|
|
108
|
+
else:
|
|
109
|
+
diff_obj = SubgroupPropRemove(subgroup_name, subgroup_property, False, DiffLevel.INFO)
|
|
110
|
+
self.diff_objs.append(diff_obj)
|
|
111
|
+
|
|
112
|
+
def __process_cmd_items(self, dict_key, cmd_name, diff_type):
|
|
113
|
+
has_cmd_key, cmd_property = extract_cmd_property(dict_key, cmd_name)
|
|
114
|
+
if not has_cmd_key:
|
|
115
|
+
if diff_type == ChangeType.REMOVE:
|
|
116
|
+
if cmd_name.split()[-1] in CMD_REMOVE_SUFFIX_WARN_LIST:
|
|
117
|
+
diff_obj = CmdRemove(cmd_name, False, DiffLevel.WARN)
|
|
118
|
+
else:
|
|
119
|
+
diff_obj = CmdRemove(cmd_name, True, DiffLevel.BREAK)
|
|
120
|
+
else:
|
|
121
|
+
diff_obj = CmdAdd(cmd_name)
|
|
122
|
+
|
|
123
|
+
self.diff_objs.append(diff_obj)
|
|
124
|
+
return
|
|
125
|
+
|
|
126
|
+
if cmd_property == "parameters":
|
|
127
|
+
self.__log_cmd_with_parameter_change(cmd_name)
|
|
128
|
+
return
|
|
129
|
+
|
|
130
|
+
if diff_type == ChangeType.ADD:
|
|
131
|
+
if cmd_property in CMD_PROPERTY_ADD_WARN_LIST:
|
|
132
|
+
diff_obj = CmdPropAdd(cmd_name, cmd_property, False, DiffLevel.WARN)
|
|
133
|
+
elif cmd_property in CMD_PROPERTY_ADD_BREAK_LIST:
|
|
134
|
+
diff_obj = CmdPropAdd(cmd_name, cmd_property, True, DiffLevel.BREAK)
|
|
135
|
+
else:
|
|
136
|
+
diff_obj = CmdPropAdd(cmd_name, cmd_property, False, DiffLevel.INFO)
|
|
137
|
+
self.diff_objs.append(diff_obj)
|
|
138
|
+
else:
|
|
139
|
+
if cmd_property in CMD_PROPERTY_REMOVE_WARN_LIST:
|
|
140
|
+
diff_obj = CmdPropRemove(cmd_name, cmd_property, False, DiffLevel.WARN)
|
|
141
|
+
elif cmd_property in CMD_PROPERTY_REMOVE_BREAK_LIST:
|
|
142
|
+
diff_obj = CmdPropRemove(cmd_name, cmd_property, True, DiffLevel.BREAK)
|
|
143
|
+
else:
|
|
144
|
+
diff_obj = CmdPropRemove(cmd_name, cmd_property, False, DiffLevel.INFO)
|
|
145
|
+
self.diff_objs.append(diff_obj)
|
|
146
|
+
|
|
77
147
|
def __iter_dict_items(self, dict_items, diff_type):
|
|
78
148
|
if diff_type not in [ChangeType.REMOVE, ChangeType.ADD]:
|
|
79
149
|
raise Exception("Unsupported dict item type")
|
|
@@ -84,49 +154,16 @@ class MetaChangeDetect:
|
|
|
84
154
|
has_subgroup, subgroup_name = extract_subgroup_name(dict_key)
|
|
85
155
|
if not has_subgroup or not subgroup_name:
|
|
86
156
|
continue
|
|
87
|
-
|
|
88
|
-
diff_obj = SubgroupRemove(subgroup_name)
|
|
89
|
-
else:
|
|
90
|
-
diff_obj = SubgroupAdd(subgroup_name)
|
|
91
|
-
self.diff_objs.append(diff_obj)
|
|
157
|
+
self.__process_subgroup_items(dict_key, subgroup_name, diff_type)
|
|
92
158
|
continue
|
|
93
|
-
|
|
94
|
-
has_cmd_key, cmd_property = extract_cmd_property(dict_key, cmd_name)
|
|
95
|
-
if has_cmd_key:
|
|
96
|
-
if cmd_property == "parameters":
|
|
97
|
-
self.__log_cmd_with_parameter_change(cmd_name)
|
|
98
|
-
elif diff_type == ChangeType.ADD:
|
|
99
|
-
if cmd_property in CMD_PROPERTY_ADD_WARN_LIST:
|
|
100
|
-
diff_obj = CmdPropAdd(cmd_name, cmd_property, False, DiffLevel.WARN)
|
|
101
|
-
elif cmd_property in CMD_PROPERTY_ADD_BREAK_LIST:
|
|
102
|
-
diff_obj = CmdPropAdd(cmd_name, cmd_property, True, DiffLevel.BREAK)
|
|
103
|
-
else:
|
|
104
|
-
diff_obj = CmdPropAdd(cmd_name, cmd_property, False, DiffLevel.INFO)
|
|
105
|
-
self.diff_objs.append(diff_obj)
|
|
106
|
-
else:
|
|
107
|
-
if cmd_property in CMD_PROPERTY_REMOVE_WARN_LIST:
|
|
108
|
-
diff_obj = CmdPropRemove(cmd_name, cmd_property, False, DiffLevel.WARN)
|
|
109
|
-
elif cmd_property in CMD_PROPERTY_REMOVE_BREAK_LIST:
|
|
110
|
-
diff_obj = CmdPropRemove(cmd_name, cmd_property, True, DiffLevel.BREAK)
|
|
111
|
-
else:
|
|
112
|
-
diff_obj = CmdPropRemove(cmd_name, cmd_property, False, DiffLevel.INFO)
|
|
113
|
-
self.diff_objs.append(diff_obj)
|
|
114
|
-
else:
|
|
115
|
-
if diff_type == ChangeType.REMOVE:
|
|
116
|
-
if cmd_name.split()[-1] in CMD_REMOVE_SUFFIX_WARN_LIST:
|
|
117
|
-
diff_obj = CmdRemove(cmd_name, False, DiffLevel.WARN)
|
|
118
|
-
else:
|
|
119
|
-
diff_obj = CmdRemove(cmd_name, True, DiffLevel.BREAK)
|
|
120
|
-
else:
|
|
121
|
-
diff_obj = CmdAdd(cmd_name)
|
|
122
|
-
|
|
123
|
-
self.diff_objs.append(diff_obj)
|
|
159
|
+
self.__process_cmd_items(dict_key, cmd_name, diff_type)
|
|
124
160
|
|
|
125
161
|
def __iter_list_items(self, list_items, diff_type):
|
|
126
162
|
"""
|
|
163
|
+
['parameters'][3]
|
|
127
164
|
['parameters'][0]['options'][1]
|
|
128
165
|
['parameters'][0]['choices'][0]
|
|
129
|
-
['parameters'][
|
|
166
|
+
['parameters'][5]['options_deprecate_info'][1]
|
|
130
167
|
"""
|
|
131
168
|
if diff_type not in [ChangeType.REMOVE, ChangeType.ADD]:
|
|
132
169
|
raise Exception("Unsupported dict item type")
|
|
@@ -167,7 +204,41 @@ class MetaChangeDetect:
|
|
|
167
204
|
list_item_add = self.deep_diff["iterable_item_added"]
|
|
168
205
|
self.__iter_list_items(list_item_add, ChangeType.ADD)
|
|
169
206
|
|
|
207
|
+
def __process_subgroup_value_change(self, key, subgroup_name, old_value, new_value):
|
|
208
|
+
has_subgroup_prop, subgroup_property = extract_subgroup_property(key, subgroup_name)
|
|
209
|
+
if not has_subgroup_prop:
|
|
210
|
+
# subgroup key does not change independently, it must be followed by some cmd property
|
|
211
|
+
return
|
|
212
|
+
if subgroup_property in SUBGROUP_PROPERTY_UPDATE_WARN_LIST:
|
|
213
|
+
diff_obj = SubgroupPropUpdate(subgroup_name, subgroup_property, False, DiffLevel.WARN, old_value, new_value)
|
|
214
|
+
elif subgroup_property in SUBGROUP_PROPERTY_UPDATE_BREAK_LIST:
|
|
215
|
+
diff_obj = SubgroupPropUpdate(subgroup_name, subgroup_property, True, DiffLevel.BREAK, old_value, new_value)
|
|
216
|
+
else:
|
|
217
|
+
diff_obj = SubgroupPropUpdate(subgroup_name, subgroup_property, False, DiffLevel.INFO, old_value, new_value)
|
|
218
|
+
self.diff_objs.append(diff_obj)
|
|
219
|
+
|
|
220
|
+
def __process_cmd_value_change(self, key, cmd_name, old_value, new_value):
|
|
221
|
+
has_cmd_prop, cmd_property = extract_cmd_property(key, cmd_name)
|
|
222
|
+
if not has_cmd_prop:
|
|
223
|
+
# cmd key does not change independently, it must followed by some cmd property
|
|
224
|
+
return
|
|
225
|
+
if cmd_property == "parameters":
|
|
226
|
+
self.__log_cmd_with_parameter_change(cmd_name)
|
|
227
|
+
return
|
|
228
|
+
|
|
229
|
+
if cmd_property in CMD_PROPERTY_UPDATE_WARN_LIST:
|
|
230
|
+
diff_obj = CmdPropUpdate(cmd_name, cmd_property, False, DiffLevel.WARN, old_value, new_value)
|
|
231
|
+
elif cmd_property in CMD_PROPERTY_UPDATE_BREAK_LIST:
|
|
232
|
+
diff_obj = CmdPropUpdate(cmd_name, cmd_property, True, DiffLevel.BREAK, old_value, new_value)
|
|
233
|
+
else:
|
|
234
|
+
diff_obj = CmdPropUpdate(cmd_name, cmd_property, False, DiffLevel.INFO, old_value, new_value)
|
|
235
|
+
self.diff_objs.append(diff_obj)
|
|
236
|
+
|
|
170
237
|
def check_value_change(self):
|
|
238
|
+
"""
|
|
239
|
+
['sub_groups']['acr']['deprecate_info_redirect']
|
|
240
|
+
['commands']['acr helm show']['deprecate_info_redirect']
|
|
241
|
+
"""
|
|
171
242
|
if not self.deep_diff.get("values_changed", None):
|
|
172
243
|
return
|
|
173
244
|
value_changes = self.deep_diff["values_changed"]
|
|
@@ -176,22 +247,13 @@ class MetaChangeDetect:
|
|
|
176
247
|
new_value = value_obj["new_value"]
|
|
177
248
|
has_cmd, cmd_name = extract_cmd_name(key)
|
|
178
249
|
if not has_cmd or not cmd_name:
|
|
179
|
-
|
|
250
|
+
has_subgroup, subgroup_name = extract_subgroup_name(key)
|
|
251
|
+
if not has_subgroup or not subgroup_name:
|
|
252
|
+
print("extract cmd or sub group failed for " + key)
|
|
253
|
+
continue
|
|
254
|
+
self.__process_subgroup_value_change(key, subgroup_name, old_value, new_value)
|
|
180
255
|
continue
|
|
181
|
-
|
|
182
|
-
has_cmd_prop, cmd_property = extract_cmd_property(key, cmd_name)
|
|
183
|
-
if not has_cmd_prop:
|
|
184
|
-
return
|
|
185
|
-
if cmd_property == "parameters":
|
|
186
|
-
self.__log_cmd_with_parameter_change(cmd_name)
|
|
187
|
-
else:
|
|
188
|
-
if cmd_property in CMD_PROPERTY_UPDATE_WARN_LIST:
|
|
189
|
-
diff_obj = CmdPropUpdate(cmd_name, cmd_property, False, DiffLevel.WARN, old_value, new_value)
|
|
190
|
-
elif cmd_property in CMD_PROPERTY_UPDATE_BREAK_LIST:
|
|
191
|
-
diff_obj = CmdPropUpdate(cmd_name, cmd_property, True, DiffLevel.BREAK, old_value, new_value)
|
|
192
|
-
else:
|
|
193
|
-
diff_obj = CmdPropUpdate(cmd_name, cmd_property, False, DiffLevel.INFO, old_value, new_value)
|
|
194
|
-
self.diff_objs.append(diff_obj)
|
|
256
|
+
self.__process_cmd_value_change(key, cmd_name, old_value, new_value)
|
|
195
257
|
|
|
196
258
|
@staticmethod
|
|
197
259
|
def __search_para_with_name_and_options(base_para_obj, search_parameters):
|
|
@@ -207,6 +269,39 @@ class MetaChangeDetect:
|
|
|
207
269
|
return para_obj
|
|
208
270
|
return None
|
|
209
271
|
|
|
272
|
+
def __process_parameter_value_update(self, cmd_name, prop, base_para_obj, base_val, cmp_val):
|
|
273
|
+
if base_val == cmp_val:
|
|
274
|
+
return
|
|
275
|
+
if prop == "options_deprecate_info":
|
|
276
|
+
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.INFO,
|
|
277
|
+
base_val, cmp_val)
|
|
278
|
+
self.diff_objs.append(diff_obj)
|
|
279
|
+
return
|
|
280
|
+
if isinstance(base_val, list) and isinstance(cmp_val, list):
|
|
281
|
+
if set(base_val).issubset(set(cmp_val)):
|
|
282
|
+
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.INFO,
|
|
283
|
+
base_val, cmp_val)
|
|
284
|
+
else:
|
|
285
|
+
if prop in PARA_PROPERTY_UPDATE_WARN_LIST:
|
|
286
|
+
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.WARN,
|
|
287
|
+
base_val, cmp_val)
|
|
288
|
+
else:
|
|
289
|
+
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, True, DiffLevel.BREAK,
|
|
290
|
+
base_val, cmp_val)
|
|
291
|
+
self.diff_objs.append(diff_obj)
|
|
292
|
+
return
|
|
293
|
+
|
|
294
|
+
if prop in PARA_PROPERTY_UPDATE_WARN_LIST:
|
|
295
|
+
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.WARN,
|
|
296
|
+
base_val, cmp_val)
|
|
297
|
+
elif prop in PARA_PROPERTY_UPDATE_BREAK_LIST:
|
|
298
|
+
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, True, DiffLevel.BREAK,
|
|
299
|
+
base_val, cmp_val)
|
|
300
|
+
else:
|
|
301
|
+
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.INFO,
|
|
302
|
+
base_val, cmp_val)
|
|
303
|
+
self.diff_objs.append(diff_obj)
|
|
304
|
+
|
|
210
305
|
def check_cmd_parameter_diff(self, cmd_name, base_parameters, cmp_parameters):
|
|
211
306
|
"""check cmd parameter diff"""
|
|
212
307
|
for base_para_obj in base_parameters:
|
|
@@ -253,29 +348,8 @@ class MetaChangeDetect:
|
|
|
253
348
|
# prop exists in both new and old para obj, value needs to be checked
|
|
254
349
|
base_val = base_para_obj[prop]
|
|
255
350
|
cmp_val = cmp_para_obj[prop]
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if isinstance(base_val, list) and isinstance(cmp_val, list):
|
|
259
|
-
if set(base_val).issubset(set(cmp_val)):
|
|
260
|
-
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.INFO,
|
|
261
|
-
base_val, cmp_val)
|
|
262
|
-
else:
|
|
263
|
-
if prop in PARA_PROPERTY_UPDATE_WARN_LIST:
|
|
264
|
-
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.WARN,
|
|
265
|
-
base_val, cmp_val)
|
|
266
|
-
else:
|
|
267
|
-
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, True, DiffLevel.BREAK,
|
|
268
|
-
base_val, cmp_val)
|
|
269
|
-
elif prop in PARA_PROPERTY_UPDATE_WARN_LIST:
|
|
270
|
-
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.WARN,
|
|
271
|
-
base_val, cmp_val)
|
|
272
|
-
elif prop in PARA_PROPERTY_UPDATE_BREAK_LIST:
|
|
273
|
-
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, True, DiffLevel.BREAK,
|
|
274
|
-
base_val, cmp_val)
|
|
275
|
-
else:
|
|
276
|
-
diff_obj = ParaPropUpdate(cmd_name, base_para_obj["name"], prop, False, DiffLevel.INFO,
|
|
277
|
-
base_val, cmp_val)
|
|
278
|
-
self.diff_objs.append(diff_obj)
|
|
351
|
+
self.__process_parameter_value_update(cmd_name, prop, base_para_obj, base_val, cmp_val)
|
|
352
|
+
continue
|
|
279
353
|
|
|
280
354
|
# check added parameter obj, if obj is required, then is break
|
|
281
355
|
for cmp_para_obj in cmp_parameters:
|
|
@@ -165,6 +165,22 @@ def extract_subgroup_name(key):
|
|
|
165
165
|
return True, subgroup_ame_res[-1]
|
|
166
166
|
|
|
167
167
|
|
|
168
|
+
def extract_subgroup_property(key, subgroup_name):
|
|
169
|
+
subgroup_key_pattern = re.compile(subgroup_name + r"\'\]\[\'([a-zA-Z0-9\-\_]+)\'\]")
|
|
170
|
+
subgroup_key_res = re.findall(subgroup_key_pattern, key)
|
|
171
|
+
if not subgroup_key_res or len(subgroup_key_res) == 0:
|
|
172
|
+
return False, None
|
|
173
|
+
return True, subgroup_key_res[0]
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def extract_subgroup_deprecate_property(key, deprecate_key):
|
|
177
|
+
subgroup_deprecate_key_pattern = re.compile(deprecate_key + r"\'\]\[\'([a-zA-Z0-9\-\_]+)\'\]")
|
|
178
|
+
subgroup_deprecate_key_res = re.findall(subgroup_deprecate_key_pattern, key)
|
|
179
|
+
if not subgroup_deprecate_key_res or len(subgroup_deprecate_key_res) == 0:
|
|
180
|
+
return False, None
|
|
181
|
+
return True, subgroup_deprecate_key_res[0]
|
|
182
|
+
|
|
183
|
+
|
|
168
184
|
def extract_cmd_name(key):
|
|
169
185
|
cmd_name_res = re.findall(CMD_NAME_PATTERN, key)
|
|
170
186
|
if not cmd_name_res or len(cmd_name_res) == 0:
|
|
@@ -180,6 +196,13 @@ def extract_cmd_property(key, cmd_name):
|
|
|
180
196
|
return True, cmd_key_res[0]
|
|
181
197
|
|
|
182
198
|
|
|
199
|
+
def extract_cmd_deprecate_property(key, deprecate_key):
|
|
200
|
+
cmd_deprecate_key_pattern = re.compile(deprecate_key + r"\'\]\[\'([a-zA-Z0-9\-\_]+)\'\]")
|
|
201
|
+
cmd_deprecate_key_res = re.findall(cmd_deprecate_key_pattern, key)
|
|
202
|
+
if not cmd_deprecate_key_res or len(cmd_deprecate_key_res) == 0:
|
|
203
|
+
return False, None
|
|
204
|
+
return True, cmd_deprecate_key_res[0]
|
|
205
|
+
|
|
183
206
|
def extract_para_info(key):
|
|
184
207
|
parameters_ind = key.find("['parameters']")
|
|
185
208
|
property_ind = key.find("[", parameters_ind + 1)
|
|
@@ -251,3 +274,22 @@ def export_meta_changes_to_dict(module_diffs, version_diff_file):
|
|
|
251
274
|
writer = csv.writer(f)
|
|
252
275
|
writer.writerows(dict_res)
|
|
253
276
|
return None
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def expand_deprecate_obj(meta_obj):
|
|
280
|
+
if type(meta_obj) is not dict:
|
|
281
|
+
return
|
|
282
|
+
for key, obj in meta_obj.items():
|
|
283
|
+
if type(obj) is dict:
|
|
284
|
+
if obj.get("deprecate_info", None):
|
|
285
|
+
for dekey, devalue in obj["deprecate_info"].items():
|
|
286
|
+
obj["deprecate_info_" + dekey] = devalue
|
|
287
|
+
del obj["deprecate_info"]
|
|
288
|
+
expand_deprecate_obj(obj)
|
|
289
|
+
elif type(obj) is list:
|
|
290
|
+
for ind, item in enumerate(obj):
|
|
291
|
+
if type(item) is dict and item.get("deprecate_info", None):
|
|
292
|
+
for dekey, devalue in item["deprecate_info"].items():
|
|
293
|
+
obj[ind]["deprecate_info_" + dekey] = devalue
|
|
294
|
+
del item["deprecate_info"]
|
|
295
|
+
expand_deprecate_obj(item)
|
{azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: azure-cli-diff-tool
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.7
|
|
4
4
|
Summary: A tool for cli metadata management
|
|
5
5
|
Author: Microsoft Corporation
|
|
6
6
|
Author-email: azpycli@microsoft.com
|
|
@@ -98,6 +98,14 @@ License
|
|
|
98
98
|
|
|
99
99
|
Release History
|
|
100
100
|
===============
|
|
101
|
+
0.0.7
|
|
102
|
+
++++++
|
|
103
|
+
* Remove unnecessary debug logs for meta comparison
|
|
104
|
+
|
|
105
|
+
0.0.6
|
|
106
|
+
++++++
|
|
107
|
+
* Add diff support for deprecate_info in subgroup, cmd, parameters and options
|
|
108
|
+
|
|
101
109
|
0.0.5
|
|
102
110
|
++++++
|
|
103
111
|
* Add `DiffLevel` to meta comparison
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# -----------------------------------------------------------------------------
|
|
6
|
+
# pylint: disable=line-too-long
|
|
7
|
+
|
|
8
|
+
import unittest
|
|
9
|
+
import os
|
|
10
|
+
from azure_cli_diff_tool import meta_diff
|
|
11
|
+
from azure_cli_diff_tool.utils import get_command_tree, extract_cmd_name, extract_cmd_property, extract_para_info, \
|
|
12
|
+
extract_subgroup_name, extract_subgroup_deprecate_property, expand_deprecate_obj, extract_subgroup_property
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class MyTestCase(unittest.TestCase):
|
|
16
|
+
|
|
17
|
+
def test_parse_cmd_tree(self):
|
|
18
|
+
cmd_name = "monitor log-profiles create"
|
|
19
|
+
ret = get_command_tree(cmd_name)
|
|
20
|
+
self.assertTrue(ret["is_group"], "group parse failed")
|
|
21
|
+
self.assertFalse(ret["sub_info"]["sub_info"]["is_group"], "group parse failed")
|
|
22
|
+
self.assertTrue(ret["sub_info"]["sub_info"]["cmd_name"] == "monitor log-profiles create", "group parse failed")
|
|
23
|
+
|
|
24
|
+
def test_diff_dict_key_parse(self):
|
|
25
|
+
test_key = "root['sub_groups']['monitor']['sub_groups']['monitor private-link-scope']['sub_groups']" \
|
|
26
|
+
"['monitor private-link-scope scoped-resource']['commands']" \
|
|
27
|
+
"['monitor private-link-scope scoped-resource list']['parameters'][0]['options'][1]"
|
|
28
|
+
has_cmd, cmd_name = extract_cmd_name(test_key)
|
|
29
|
+
self.assertTrue(has_cmd, "cmd parse failed from diff dict key")
|
|
30
|
+
self.assertEqual(cmd_name, "monitor private-link-scope scoped-resource list", "cmd name extract failed")
|
|
31
|
+
has_cmd_key, cmd_key = extract_cmd_property(test_key, cmd_name)
|
|
32
|
+
self.assertTrue(has_cmd_key, "cmd property parse failed from diff dict key")
|
|
33
|
+
self.assertEqual(cmd_key, "parameters", "cmd property extract failed")
|
|
34
|
+
para_res = extract_para_info(test_key)
|
|
35
|
+
self.assertEqual(para_res[0], "0", "cmd parameter parse failed")
|
|
36
|
+
|
|
37
|
+
def test_diff_dict_key_for_subgroups(self):
|
|
38
|
+
test_key = "root['sub_groups']['monitor']['sub_groups']['monitor account']"
|
|
39
|
+
has_cmd, _ = extract_cmd_name(test_key)
|
|
40
|
+
self.assertFalse(has_cmd, "cmd parse error from diff dict key")
|
|
41
|
+
has_subgroup, subgroup_name = extract_subgroup_name(test_key)
|
|
42
|
+
self.assertTrue(has_subgroup, "sub group parse failed from diff dict key")
|
|
43
|
+
self.assertEqual(subgroup_name, "monitor account", "sub group name extract failed")
|
|
44
|
+
|
|
45
|
+
def test_diff_dict_key_for_subgroups_deprecate_info(self):
|
|
46
|
+
test_key = "root['sub_groups']['acr']['deprecate_info']['hide']"
|
|
47
|
+
has_cmd, _ = extract_cmd_name(test_key)
|
|
48
|
+
self.assertFalse(has_cmd, "cmd parse error from diff dict key")
|
|
49
|
+
has_subgroup, subgroup_name = extract_subgroup_name(test_key)
|
|
50
|
+
self.assertTrue(has_subgroup, "sub group parse failed from diff dict key")
|
|
51
|
+
self.assertEqual(subgroup_name, "acr", "sub group name extract failed")
|
|
52
|
+
has_subgroup_deprecate_prop, subgroup_deprecate_prop = extract_subgroup_deprecate_property(test_key, "deprecate_info")
|
|
53
|
+
self.assertTrue(has_subgroup_deprecate_prop, "sub group deprecate info prop parse failed from diff dict key")
|
|
54
|
+
self.assertEqual(subgroup_deprecate_prop, "hide", "sub group deprecate prop extract failed")
|
|
55
|
+
|
|
56
|
+
def test_diff_dict_key_for_subgroups_prop(self):
|
|
57
|
+
test_key = "root['sub_groups']['acr']['deprecate_info_hide']"
|
|
58
|
+
has_cmd, _ = extract_cmd_name(test_key)
|
|
59
|
+
self.assertFalse(has_cmd, "cmd parse error from diff dict key")
|
|
60
|
+
has_subgroup, subgroup_name = extract_subgroup_name(test_key)
|
|
61
|
+
self.assertTrue(has_subgroup, "sub group parse failed from diff dict key")
|
|
62
|
+
self.assertEqual(subgroup_name, "acr", "sub group name extract failed")
|
|
63
|
+
has_subgroup_prop, subgroup_prop = extract_subgroup_property(test_key, subgroup_name)
|
|
64
|
+
self.assertTrue(has_subgroup_prop, "sub group prop parse failed from diff dict key")
|
|
65
|
+
self.assertEqual(subgroup_prop, "deprecate_info_hide", "sub group prop extract failed")
|
|
66
|
+
|
|
67
|
+
def test_diff_meta(self):
|
|
68
|
+
if not os.path.exists("./jsons/az_monitor_meta_before.json") \
|
|
69
|
+
or not os.path.exists("./jsons/az_monitor_meta_after.json"):
|
|
70
|
+
return
|
|
71
|
+
result = meta_diff(base_meta_file="./jsons/az_monitor_meta_before.json",
|
|
72
|
+
diff_meta_file="./jsons/az_monitor_meta_after.json",
|
|
73
|
+
output_type="text")
|
|
74
|
+
target_message = [
|
|
75
|
+
"please confirm cmd `monitor private-link-scope scoped-resource show` removed",
|
|
76
|
+
"sub group `monitor private-link-scope private-endpoint-connection cust` removed",
|
|
77
|
+
"cmd `monitor private-link-scope private-link-resource list` update parameter `scope_name`: added property `type=string`",
|
|
78
|
+
"cmd `monitor private-link-scope private-link-resource list` update parameter `resource_group_name`: removed property `id_part=resource_group` | diff_level: 2"
|
|
79
|
+
]
|
|
80
|
+
for mes in target_message:
|
|
81
|
+
found = False
|
|
82
|
+
for line in result:
|
|
83
|
+
if line.find(mes) > -1:
|
|
84
|
+
found = True
|
|
85
|
+
break
|
|
86
|
+
self.assertTrue(found, "target message not found")
|
|
87
|
+
|
|
88
|
+
ignored_message = [
|
|
89
|
+
"updated property `is_aaz` from `False` to `True`"
|
|
90
|
+
]
|
|
91
|
+
for mes in ignored_message:
|
|
92
|
+
ignored = True
|
|
93
|
+
for line in result:
|
|
94
|
+
if line.find(mes) > -1:
|
|
95
|
+
ignored = False
|
|
96
|
+
break
|
|
97
|
+
self.assertTrue(ignored, "ignored message found")
|
|
98
|
+
|
|
99
|
+
def test_diff_meta_whitelist(self):
|
|
100
|
+
if not os.path.exists("./jsons/az_ams_meta_before.json") \
|
|
101
|
+
or not os.path.exists("./jsons/az_ams_meta_after.json"):
|
|
102
|
+
return
|
|
103
|
+
result = meta_diff(base_meta_file="./jsons/az_ams_meta_before.json",
|
|
104
|
+
diff_meta_file="./jsons/az_ams_meta_after.json",
|
|
105
|
+
output_type="text")
|
|
106
|
+
self.assertEqual(result, [], "returned change isn't empty")
|
|
107
|
+
|
|
108
|
+
def test_expand_deprecate_obj(self):
|
|
109
|
+
example_obj = {
|
|
110
|
+
"module_name": "acr",
|
|
111
|
+
"name": "az",
|
|
112
|
+
"commands": {},
|
|
113
|
+
"sub_groups": {
|
|
114
|
+
"acr": {
|
|
115
|
+
"name": "acr",
|
|
116
|
+
"commands": {
|
|
117
|
+
"acr helm list": {
|
|
118
|
+
"name": "acr helm list",
|
|
119
|
+
"parameters": [{
|
|
120
|
+
"name": "resource_group_name",
|
|
121
|
+
"deprecate_info": {
|
|
122
|
+
"redirect": "resource_group_name2",
|
|
123
|
+
},
|
|
124
|
+
"options": ["--resource-group", "-g"],
|
|
125
|
+
"id_part": "resource_group"
|
|
126
|
+
}, {
|
|
127
|
+
"name": "password",
|
|
128
|
+
"options": ["--password", "-p"],
|
|
129
|
+
"options_deprecate_info": [{
|
|
130
|
+
"target": "--password",
|
|
131
|
+
"redirect": "--registry-password",
|
|
132
|
+
}]
|
|
133
|
+
}]
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"deprecate_info": {
|
|
137
|
+
"target": "acr",
|
|
138
|
+
"redirect": "acr3",
|
|
139
|
+
"hide": True
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
expand_deprecate_obj(example_obj)
|
|
145
|
+
self.assertEqual(example_obj["sub_groups"]["acr"]["deprecate_info_target"], "acr",
|
|
146
|
+
"deprecate info expand not working properly")
|
|
147
|
+
self.assertEqual(example_obj["sub_groups"]["acr"]["deprecate_info_redirect"], "acr3",
|
|
148
|
+
"deprecate info expand not working properly")
|
|
149
|
+
self.assertEqual(example_obj["sub_groups"]["acr"]["commands"]["acr helm list"]["parameters"][0]["deprecate_info_redirect"], "resource_group_name2", "deprecate info expand not working properly")
|
|
150
|
+
|
|
151
|
+
def test_diff_meta_for_deprecate_info(self):
|
|
152
|
+
if not os.path.exists("./jsons/az_acr_meta_before.json") or not os.path.exists("./jsons/az_acr_meta_after.json"):
|
|
153
|
+
return
|
|
154
|
+
result = meta_diff(base_meta_file="./jsons/az_acr_meta_before.json",
|
|
155
|
+
diff_meta_file="./jsons/az_acr_meta_after.json",
|
|
156
|
+
output_type="text")
|
|
157
|
+
target_message = [
|
|
158
|
+
"sub group `acr` added property `deprecate_info_hide` | diff_level: 2",
|
|
159
|
+
"sub group `acr` updated property `deprecate_info_redirect` from `acr2` to `acr3` | diff_level: 1",
|
|
160
|
+
"sub group `acr helm` removed property `deprecate_info_target` | diff_level: 1",
|
|
161
|
+
"sub group `acr helm` removed property `deprecate_info_redirect` | diff_level: 2",
|
|
162
|
+
"cmd `acr helm list` removed property `deprecate_info_target` | diff_level: 1",
|
|
163
|
+
"cmd `acr helm list` removed property `deprecate_info_redirect` | diff_level: 2",
|
|
164
|
+
"cmd `acr helm list` removed property `deprecate_info_hide` | diff_level: 1",
|
|
165
|
+
"cmd `acr helm show` updated property `deprecate_info_redirect` from `acr helm show2` to `acr helm show3` | diff_level: 2",
|
|
166
|
+
"cmd `acr helm list` update parameter `repository`: removed property `options_deprecate_info=",
|
|
167
|
+
]
|
|
168
|
+
for mes in target_message:
|
|
169
|
+
found = False
|
|
170
|
+
for line in result:
|
|
171
|
+
if line.find(mes) > -1:
|
|
172
|
+
found = True
|
|
173
|
+
break
|
|
174
|
+
print(mes)
|
|
175
|
+
self.assertTrue(found, "target message not found")
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
if __name__ == '__main__':
|
|
179
|
+
unittest.main()
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# -----------------------------------------------------------------------------
|
|
2
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
-
# license information.
|
|
5
|
-
# -----------------------------------------------------------------------------
|
|
6
|
-
# pylint: disable=line-too-long
|
|
7
|
-
|
|
8
|
-
import unittest
|
|
9
|
-
import os
|
|
10
|
-
from azure_cli_diff_tool import meta_diff
|
|
11
|
-
from azure_cli_diff_tool.utils import get_command_tree, extract_cmd_name, extract_cmd_property, extract_para_info, \
|
|
12
|
-
extract_subgroup_name
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class MyTestCase(unittest.TestCase):
|
|
16
|
-
|
|
17
|
-
def test_parse_cmd_tree(self):
|
|
18
|
-
cmd_name = "monitor log-profiles create"
|
|
19
|
-
ret = get_command_tree(cmd_name)
|
|
20
|
-
self.assertTrue(ret["is_group"], "group parse failed")
|
|
21
|
-
self.assertFalse(ret["sub_info"]["sub_info"]["is_group"], "group parse failed")
|
|
22
|
-
self.assertTrue(ret["sub_info"]["sub_info"]["cmd_name"] == "monitor log-profiles create", "group parse failed")
|
|
23
|
-
|
|
24
|
-
def test_diff_dict_key_parse(self):
|
|
25
|
-
test_key = "root['sub_groups']['monitor']['sub_groups']['monitor private-link-scope']['sub_groups']" \
|
|
26
|
-
"['monitor private-link-scope scoped-resource']['commands']" \
|
|
27
|
-
"['monitor private-link-scope scoped-resource list']['parameters'][0]['options'][1]"
|
|
28
|
-
has_cmd, cmd_name = extract_cmd_name(test_key)
|
|
29
|
-
self.assertTrue(has_cmd, "cmd parse failed from diff dict key")
|
|
30
|
-
self.assertEqual(cmd_name, "monitor private-link-scope scoped-resource list", "cmd name extract failed")
|
|
31
|
-
has_cmd_key, cmd_key = extract_cmd_property(test_key, cmd_name)
|
|
32
|
-
self.assertTrue(has_cmd_key, "cmd property parse failed from diff dict key")
|
|
33
|
-
self.assertEqual(cmd_key, "parameters", "cmd property extract failed")
|
|
34
|
-
para_res = extract_para_info(test_key)
|
|
35
|
-
self.assertEqual(para_res[0], "0", "cmd parameter parse failed")
|
|
36
|
-
|
|
37
|
-
def test_diff_dict_key_for_subgroups(self):
|
|
38
|
-
test_key = "root['sub_groups']['monitor']['sub_groups']['monitor account']"
|
|
39
|
-
has_cmd, _ = extract_cmd_name(test_key)
|
|
40
|
-
self.assertFalse(has_cmd, "cmd parse error from diff dict key")
|
|
41
|
-
has_subgroup, subgroup_name = extract_subgroup_name(test_key)
|
|
42
|
-
self.assertTrue(has_subgroup, "sub group parse failed from diff dict key")
|
|
43
|
-
self.assertEqual(subgroup_name, "monitor account", "sub group name extract failed")
|
|
44
|
-
|
|
45
|
-
def test_diff_meta(self):
|
|
46
|
-
if not os.path.exists("./jsons/az_monitor_meta_before.json") \
|
|
47
|
-
or not os.path.exists("./jsons/az_monitor_meta_after.json"):
|
|
48
|
-
return
|
|
49
|
-
result = meta_diff(base_meta_file="./jsons/az_monitor_meta_before.json",
|
|
50
|
-
diff_meta_file="./jsons/az_monitor_meta_after.json",
|
|
51
|
-
output_type="text")
|
|
52
|
-
target_message = [
|
|
53
|
-
"please confirm cmd `monitor private-link-scope scoped-resource show` removed",
|
|
54
|
-
"sub group `monitor private-link-scope private-endpoint-connection cust` removed",
|
|
55
|
-
"cmd `monitor private-link-scope private-link-resource list` update parameter `scope_name`: added property `type=string`",
|
|
56
|
-
"cmd `monitor private-link-scope private-link-resource list` update parameter `resource_group_name`: removed property `id_part=resource_group` | diff_level: 2"
|
|
57
|
-
]
|
|
58
|
-
for mes in target_message:
|
|
59
|
-
found = False
|
|
60
|
-
for line in result:
|
|
61
|
-
if line.find(mes) > -1:
|
|
62
|
-
found = True
|
|
63
|
-
break
|
|
64
|
-
self.assertTrue(found, "target message not found")
|
|
65
|
-
|
|
66
|
-
ignored_message = [
|
|
67
|
-
"updated property `is_aaz` from `False` to `True`"
|
|
68
|
-
]
|
|
69
|
-
for mes in ignored_message:
|
|
70
|
-
ignored = True
|
|
71
|
-
for line in result:
|
|
72
|
-
if line.find(mes) > -1:
|
|
73
|
-
ignored = False
|
|
74
|
-
break
|
|
75
|
-
self.assertTrue(ignored, "ignored message found")
|
|
76
|
-
|
|
77
|
-
def test_diff_meta_whitelist(self):
|
|
78
|
-
if not os.path.exists("./jsons/az_ams_meta_before.json") \
|
|
79
|
-
or not os.path.exists("./jsons/az_ams_meta_after.json"):
|
|
80
|
-
return
|
|
81
|
-
result = meta_diff(base_meta_file="./jsons/az_ams_meta_before.json",
|
|
82
|
-
diff_meta_file="./jsons/az_ams_meta_after.json",
|
|
83
|
-
output_type="text")
|
|
84
|
-
self.assertEqual(result, [], "returned change isn't empty")
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if __name__ == '__main__':
|
|
88
|
-
unittest.main()
|
|
File without changes
|
{azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool/data/blob_config.ini
RENAMED
|
File without changes
|
|
File without changes
|
{azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/requires.txt
RENAMED
|
File without changes
|
{azure-cli-diff-tool-0.0.5 → azure_cli_diff_tool-0.0.7}/azure_cli_diff_tool.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|