Skip to content

Commit e370b9a

Browse files
authored
fix module name index for extension json (#432)
* fix module name index
1 parent 82a1c3b commit e370b9a

6 files changed

Lines changed: 346 additions & 5 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.64
6+
++++++
7+
* `azdev extension cal-next-version`: Fix module name when querying extension modules from index.
8+
59
0.1.63
610
++++++
711
* `azdev`: Update required version for `azure-cli-diff-tool`.

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.63'
7+
__VERSION__ = '0.1.64'

azdev/operations/extensions/version_upgrade.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# -----------------------------------------------------------------------------
66
# pylint: disable=line-too-long
77

8-
# NOTE: The version uodate rules in this doc is complied with the doc below
8+
# NOTE: The version update rules in this doc comply with the doc below
99
# https://github.com/Azure/azure-cli/blob/release/doc/extensions/versioning_guidelines.md
1010

1111
from packaging.version import parse
@@ -56,7 +56,7 @@ def __init__(self, module_name, current_version, is_preview, is_experimental,
5656
self.version = parse(current_version)
5757
except Exception as e:
5858
raise ValueError("Invalid version: {0} cause {1}".format(current_version, str(e)))
59-
self.is_preview = bool(is_preview or is_experimental or (self.version.pre and self.version.pre in ["a", "b"]))
59+
self.is_preview = bool(is_preview or is_experimental or (self.version.pre and self.version.pre[0] in ["a", "b"]))
6060
self.has_preview_tag = is_preview
6161
self.has_exp_tag = is_experimental
6262
self.version_raw = current_version
@@ -92,7 +92,7 @@ def init_version_diffs(self):
9292
def init_version_pre_tag(self):
9393
"""
9494
use next version pre tag if user inputs
95-
otherwise, consistant with the preview tag
95+
otherwise, consistent with the preview tag
9696
"""
9797
if self.next_version_pre_tag is not None:
9898
return
@@ -187,9 +187,11 @@ def parse_last_stable_major(self):
187187
if self.module_name not in extension_data["extensions"]:
188188
return
189189
has_stable, max_stable_major = self.find_max_version(
190-
extension_data["extensions"][self.base_meta_file["module_name"]])
190+
extension_data["extensions"][self.module_name])
191191
if has_stable:
192192
self.last_stable_major = max_stable_major
193+
else:
194+
self.last_stable_major = 0
193195
except Exception as e:
194196
raise ValueError(str(e))
195197

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
{
2+
"module_name": "costmanagement",
3+
"name": "az",
4+
"commands": {},
5+
"sub_groups": {
6+
"costmanagement": {
7+
"name": "costmanagement",
8+
"commands": {
9+
"costmanagement show-operation-result": {
10+
"name": "costmanagement show-operation-result",
11+
"is_aaz": true,
12+
"supports_no_wait": true,
13+
"parameters": [{
14+
"name": "no_wait",
15+
"options": ["--no-wait"],
16+
"choices": ["0", "1", "f", "false", "n", "no", "t", "true", "y", "yes"],
17+
"nargs": "?",
18+
"aaz_type": "bool",
19+
"type": "bool"
20+
}, {
21+
"name": "operation_id",
22+
"options": ["--operation-id"],
23+
"required": true,
24+
"aaz_type": "string",
25+
"type": "string"
26+
}, {
27+
"name": "scope",
28+
"options": ["--scope"],
29+
"required": true,
30+
"aaz_type": "string",
31+
"type": "string"
32+
}]
33+
}
34+
},
35+
"sub_groups": {
36+
"costmanagement export": {
37+
"name": "costmanagement export",
38+
"commands": {
39+
"costmanagement export list": {
40+
"name": "costmanagement export list",
41+
"is_aaz": false,
42+
"parameters": [{
43+
"name": "scope",
44+
"options": ["--scope"],
45+
"required": true
46+
}]
47+
},
48+
"costmanagement export show": {
49+
"name": "costmanagement export show",
50+
"is_aaz": false,
51+
"parameters": [{
52+
"name": "scope",
53+
"options": ["--scope"],
54+
"required": true
55+
}, {
56+
"name": "export_name",
57+
"options": ["--name"],
58+
"required": true
59+
}]
60+
},
61+
"costmanagement export create": {
62+
"name": "costmanagement export create",
63+
"is_aaz": false,
64+
"parameters": [{
65+
"name": "scope",
66+
"options": ["--scope"],
67+
"required": true
68+
}, {
69+
"name": "export_name",
70+
"options": ["--name"],
71+
"required": true
72+
}, {
73+
"name": "delivery_storage_container",
74+
"options": ["--storage-container"],
75+
"required": true
76+
}, {
77+
"name": "delivery_storage_account_id",
78+
"options": ["--storage-account-id"],
79+
"required": true
80+
}, {
81+
"name": "definition_timeframe",
82+
"options": ["--timeframe"],
83+
"required": true,
84+
"choices": ["BillingMonthToDate", "Custom", "MonthToDate", "TheLastBillingMonth", "TheLastMonth", "WeekToDate"]
85+
}, {
86+
"name": "delivery_directory",
87+
"options": ["--storage-directory"]
88+
}, {
89+
"name": "definition_type",
90+
"options": ["--type"],
91+
"choices": ["ActualCost", "AmortizedCost", "Usage"],
92+
"default": "Usage"
93+
}, {
94+
"name": "definition_time_period",
95+
"options": ["--time-period"],
96+
"nargs": "+"
97+
}, {
98+
"name": "definition_dataset_configuration",
99+
"options": ["--dataset-configuration"],
100+
"nargs": "+"
101+
}, {
102+
"name": "schedule_status",
103+
"options": ["--schedule-status"],
104+
"choices": ["Active", "Inactive"],
105+
"default": "Inactive"
106+
}, {
107+
"name": "schedule_recurrence",
108+
"options": ["--recurrence"],
109+
"choices": ["Annually", "Daily", "Monthly", "Weekly"]
110+
}, {
111+
"name": "schedule_recurrence_period",
112+
"options": ["--recurrence-period"],
113+
"nargs": "+"
114+
}]
115+
},
116+
"costmanagement export delete": {
117+
"name": "costmanagement export delete",
118+
"is_aaz": false,
119+
"confirmation": true,
120+
"parameters": [{
121+
"name": "scope",
122+
"options": ["--scope"],
123+
"required": true
124+
}, {
125+
"name": "export_name",
126+
"options": ["--name"],
127+
"required": true
128+
}, {
129+
"name": "yes",
130+
"options": ["--yes", "-y"]
131+
}]
132+
}
133+
},
134+
"sub_groups": {}
135+
}
136+
}
137+
}
138+
}
139+
}
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
{
2+
"module_name": "costmanagement",
3+
"name": "az",
4+
"commands": {},
5+
"sub_groups": {
6+
"costmanagement": {
7+
"name": "costmanagement",
8+
"commands": {
9+
"costmanagement show-operation-result": {
10+
"name": "costmanagement show-operation-result",
11+
"is_aaz": true,
12+
"supports_no_wait": true,
13+
"parameters": [{
14+
"name": "no_wait",
15+
"options": ["--no-wait"],
16+
"choices": ["0", "1", "f", "false", "n", "no", "t", "true", "y", "yes"],
17+
"nargs": "?",
18+
"aaz_type": "bool",
19+
"type": "bool"
20+
}, {
21+
"name": "operation_id",
22+
"options": ["--operation-id"],
23+
"required": true,
24+
"aaz_type": "string",
25+
"type": "string"
26+
}, {
27+
"name": "scope",
28+
"options": ["--scope"],
29+
"required": true,
30+
"aaz_type": "string",
31+
"type": "string"
32+
}]
33+
}
34+
},
35+
"sub_groups": {
36+
"costmanagement export": {
37+
"name": "costmanagement export",
38+
"commands": {
39+
"costmanagement export list": {
40+
"name": "costmanagement export list",
41+
"is_aaz": false,
42+
"parameters": [{
43+
"name": "scope",
44+
"options": ["--scope"],
45+
"required": true
46+
}]
47+
},
48+
"costmanagement export show": {
49+
"name": "costmanagement export show",
50+
"is_aaz": false,
51+
"parameters": [{
52+
"name": "scope",
53+
"options": ["--scope"],
54+
"required": true
55+
}, {
56+
"name": "export_name",
57+
"options": ["--name"],
58+
"required": true
59+
}]
60+
},
61+
"costmanagement export create": {
62+
"name": "costmanagement export create",
63+
"is_aaz": false,
64+
"parameters": [{
65+
"name": "scope",
66+
"options": ["--scope"],
67+
"required": true
68+
}, {
69+
"name": "export_name",
70+
"options": ["--name"],
71+
"required": true
72+
}, {
73+
"name": "delivery_storage_container",
74+
"options": ["--storage-container"],
75+
"required": true
76+
}, {
77+
"name": "delivery_storage_account_id",
78+
"options": ["--storage-account-id"],
79+
"required": true
80+
}, {
81+
"name": "definition_timeframe",
82+
"options": ["--timeframe"],
83+
"required": true,
84+
"choices": ["BillingMonthToDate", "Custom", "MonthToDate", "TheLastBillingMonth", "TheLastMonth", "WeekToDate"]
85+
}, {
86+
"name": "delivery_directory",
87+
"options": ["--storage-directory"]
88+
}, {
89+
"name": "definition_type",
90+
"options": ["--type"],
91+
"choices": ["ActualCost", "AmortizedCost", "Usage"],
92+
"default": "Usage"
93+
}, {
94+
"name": "definition_time_period",
95+
"options": ["--time-period"],
96+
"nargs": "+"
97+
}, {
98+
"name": "definition_dataset_configuration",
99+
"options": ["--dataset-configuration"],
100+
"nargs": "+"
101+
}, {
102+
"name": "schedule_status",
103+
"options": ["--schedule-status"],
104+
"choices": ["Active", "Inactive"],
105+
"default": "Inactive"
106+
}, {
107+
"name": "schedule_recurrence",
108+
"options": ["--recurrence"],
109+
"choices": ["Annually", "Daily", "Monthly", "Weekly"]
110+
}, {
111+
"name": "schedule_recurrence_period",
112+
"options": ["--recurrence-period"],
113+
"nargs": "+"
114+
}]
115+
},
116+
"costmanagement export update": {
117+
"name": "costmanagement export update",
118+
"is_aaz": false,
119+
"parameters": [{
120+
"name": "scope",
121+
"options": ["--scope"],
122+
"required": true
123+
}, {
124+
"name": "export_name",
125+
"options": ["--name"],
126+
"required": true
127+
}, {
128+
"name": "delivery_storage_container",
129+
"options": ["--storage-container"]
130+
}, {
131+
"name": "delivery_storage_account_id",
132+
"options": ["--storage-account-id"]
133+
}, {
134+
"name": "delivery_directory",
135+
"options": ["--storage-directory"]
136+
}, {
137+
"name": "definition_timeframe",
138+
"options": ["--timeframe"],
139+
"choices": ["BillingMonthToDate", "Custom", "MonthToDate", "TheLastBillingMonth", "TheLastMonth", "WeekToDate"]
140+
}, {
141+
"name": "definition_time_period",
142+
"options": ["--time-period"],
143+
"nargs": "+"
144+
}, {
145+
"name": "definition_dataset_configuration",
146+
"options": ["--dataset-configuration"],
147+
"nargs": "+"
148+
}, {
149+
"name": "schedule_status",
150+
"options": ["--schedule-status"],
151+
"choices": ["Active", "Inactive"]
152+
}, {
153+
"name": "schedule_recurrence",
154+
"options": ["--recurrence"],
155+
"choices": ["Annually", "Daily", "Monthly", "Weekly"]
156+
}, {
157+
"name": "schedule_recurrence_period",
158+
"options": ["--recurrence-period"],
159+
"nargs": "+"
160+
}]
161+
},
162+
"costmanagement export delete": {
163+
"name": "costmanagement export delete",
164+
"is_aaz": false,
165+
"confirmation": true,
166+
"parameters": [{
167+
"name": "scope",
168+
"options": ["--scope"],
169+
"required": true
170+
}, {
171+
"name": "export_name",
172+
"options": ["--name"],
173+
"required": true
174+
}, {
175+
"name": "yes",
176+
"options": ["--yes", "-y"]
177+
}]
178+
}
179+
},
180+
"sub_groups": {}
181+
}
182+
}
183+
}
184+
}
185+
}

azdev/operations/tests/test_extension_versioning.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,14 @@ def test_version_upgrade_patch(self):
7979
diff_meta_file=os.path.join(TEST_DIR, "jsons", "az_ams_meta_after.json"),
8080
current_version="3.11.0")
8181
self.assertEqual("3.11.1", version_test.get("version"), "Version cal error")
82+
83+
def test_version_upgrade_preview_break(self):
84+
# preview version update while no stable version before or stable version already lower in major
85+
version_test = cal_next_version(base_meta_file=os.path.join(TEST_DIR, "jsons",
86+
"az_costmanagement_meta_before.json"),
87+
diff_meta_file=os.path.join(TEST_DIR, "jsons",
88+
"az_costmanagement_meta_after.json"),
89+
current_version="1.0.0b3")
90+
self.assertEqual("1.0.0b4", version_test.get("version"), "Version cal error")
91+
self.assertEqual(False, version_test.get("is_stable"), "Version tag error")
92+
self.assertEqual(False, version_test.get("has_preview_tag"), "Version tag error")

0 commit comments

Comments
 (0)