|
23 | 23 | import json |
24 | 24 | import re |
25 | 25 | import sys |
26 | | -from datetime import datetime |
27 | 26 | from pathlib import Path |
28 | 27 |
|
29 | 28 | # --------------------------------------------------------------------------- |
@@ -140,7 +139,7 @@ def update_nap_sc_row(sc_row, nap_waf_version): |
140 | 139 | """ |
141 | 140 | if nap_waf_version and "+" in nap_waf_version: |
142 | 141 | new_prefix = nap_waf_version.split("+")[0] |
143 | | - m = re.search(r"(\d+)\+", sc_row) |
| 142 | + m = re.search(r"(\d+(?:\.\d+)*)\+", sc_row) |
144 | 143 | if m and m.group(1) != new_prefix: |
145 | 144 | return sc_row.replace(m.group(1) + "+", new_prefix + "+", 1) |
146 | 145 | return sc_row |
@@ -171,56 +170,35 @@ def generate_compat_table_md(json_data, sc_row=None): |
171 | 170 | used as-is to preserve original formatting. Otherwise a fresh shortcode |
172 | 171 | row is generated from the JSON shortcode_row values. |
173 | 172 |
|
174 | | - Prunes rows past their End of Technical Support date, keeping the most |
175 | | - recently expired row as a reference. |
176 | 173 | """ |
177 | 174 | sr = json_data["nic_k8s"]["shortcode_row"] |
178 | 175 | rows = json_data["nic_k8s"]["rows"] |
179 | 176 |
|
| 177 | + if sc_row is not None: |
| 178 | + col_count = len(sc_row.split("|")[1:-1]) |
| 179 | + if col_count != 5: |
| 180 | + sc_row = None |
| 181 | + |
180 | 182 | header = ( |
181 | 183 | "| NIC version | Kubernetes versions tested " |
182 | 184 | "| NIC Helm Chart version | NIC Operator version " |
183 | | - "| NGINX / NGINX Plus version | End of Technical Support |" |
| 185 | + "| NGINX / NGINX Plus version |" |
184 | 186 | ) |
185 | | - sep = "| --- | --- | --- | --- | --- | --- |" |
| 187 | + sep = "| --- | --- | --- | --- | --- |" |
186 | 188 |
|
187 | 189 | if sc_row is None: |
188 | 190 | sc_row = ( |
189 | 191 | f"| {{{{< nic-version >}}}} | {sr['k8s_versions']} " |
190 | 192 | f"| {{{{< nic-helm-version >}}}} | {{{{< nic-operator-version >}}}} " |
191 | | - f"| {sr['nginx_version']} | - |" |
| 193 | + f"| {sr['nginx_version']} |" |
192 | 194 | ) |
193 | 195 |
|
194 | | - # EOTS pruning |
195 | | - now = datetime.now() |
196 | | - active_rows = [] |
197 | | - expired_rows = [] |
198 | | - for row in rows: |
199 | | - eots = row.get("eots_date", "-") |
200 | | - if eots and eots != "-": |
201 | | - try: |
202 | | - eots_date = datetime.strptime(eots, "%b %d, %Y") |
203 | | - if now > eots_date: |
204 | | - expired_rows.append((eots_date, row)) |
205 | | - continue |
206 | | - except ValueError: |
207 | | - # End of Technical Support value doesn't match expected date format — keep the row rather than pruning it. |
208 | | - print( |
209 | | - f"WARNING: Could not parse End of Technical Support date '{eots}' for NIC version '{row.get('nic_version', 'unknown')}', keeping row" |
210 | | - ) |
211 | | - active_rows.append(row) |
212 | | - |
213 | | - # Keep the most recently expired row as a migration reference |
214 | | - if expired_rows: |
215 | | - expired_rows.sort(key=lambda x: x[0], reverse=True) |
216 | | - active_rows.append(expired_rows[0][1]) |
217 | | - |
218 | 196 | data_lines = [] |
219 | | - for row in active_rows: |
| 197 | + for row in rows: |
220 | 198 | data_lines.append( |
221 | 199 | f"| {row['nic_version']} | {row['k8s_versions']} " |
222 | 200 | f"| {row['helm_version']} | {row['operator_version']} " |
223 | | - f"| {row['nginx_version']} | {row['eots_date']} |" |
| 201 | + f"| {row['nginx_version']} |" |
224 | 202 | ) |
225 | 203 |
|
226 | 204 | return "\n".join([header, sep, sc_row] + data_lines) |
@@ -303,14 +281,14 @@ def update_nginx_prose(md, nginx_new): |
303 | 281 | if oss_match: |
304 | 282 | current_oss = oss_match.group(1) |
305 | 283 | if current_oss != new_oss: |
306 | | - md = re.sub(r"\b" + re.escape(current_oss) + r"\b", new_oss, md) |
| 284 | + md = re.sub(r"\b" + re.escape(current_oss) + r"(?!\.?\d)", new_oss, md) |
307 | 285 |
|
308 | 286 | if new_plus: |
309 | | - plus_match = re.search(r"NGINX Plus images include NGINX Plus (R\d+(?:\s+P\d+)?)", md) |
| 287 | + plus_match = re.search(r"NGINX Plus images include NGINX Plus (R\d+(?:\.\d+)*(?:\s+P\d+)?)", md) |
310 | 288 | if plus_match: |
311 | 289 | current_plus = plus_match.group(1) |
312 | 290 | if current_plus != new_plus: |
313 | | - md = re.sub(r"\b" + re.escape(current_plus) + r"\b", new_plus, md) |
| 291 | + md = re.sub(r"\b" + re.escape(current_plus) + r"(?!\.?\d)", new_plus, md) |
314 | 292 |
|
315 | 293 | return md |
316 | 294 |
|
@@ -340,7 +318,6 @@ def freeze_compat_row(json_data, current_nic, current_helm, current_operator): |
340 | 318 | "helm_version": current_helm, |
341 | 319 | "operator_version": current_operator, |
342 | 320 | "nginx_version": sr["nginx_version"], |
343 | | - "eots_date": "-", |
344 | 321 | } |
345 | 322 | json_data["nic_k8s"]["rows"].insert(0, frozen) |
346 | 323 | print(f"INFO: Frozen compat row for {current_nic}") |
|
0 commit comments