fix(k8s): 可视化编辑器 YAML 解析失败(managedFields 清理)

- 先解析原始 YAML 再对象级剥离,避免 cleanYAML 破坏结构
- managedFields 从 METADATA_LINE_KEYS 移除,改整块删除含数组项
- YamlViewer 同步使用 parseEditableManifest
This commit is contained in:
Logan.Li committed 2026-06-26 14:53:20 +08:00
1 parent 21d40b186a
commit 5fad2db0c6
101 files changed
+195 -146

No files matched your search

@@ -22,7 +22,8 @@ export function cleanYAML(yaml: string): string {
// ===== 移除配置 =====
const METADATA_LINE_KEYS = new Set([
'uid', 'resourceVersion', 'creationTimestamp', 'generation',
'selfLink', 'clusterName', 'managedFields', 'generateName',
'selfLink', 'clusterName', 'generateName',
// managedFields 走 METADATA_BLOCK_KEYS 整块删除(含同级数组项)// Logan.Li
]);
const METADATA_BLOCK_KEYS = new Set(['managedFields', 'ownerReferences']);
@@ -185,8 +186,17 @@ export function cleanYAML(yaml: string): string {
}
// metadata 块字段移除(managedFields/ownerReferences)
// K8s 数组项与 key 同级缩进(如 managedFields:\n - apiVersion),需一并跳过 // Logan.Li
if (indent === metaIndent && key && METADATA_BLOCK_KEYS.has(key)) {
skipBlock(metaIndent);
i++;
while (i < lines.length) {
const l = lines[i];
const t = l.trimStart();
if (t === '' || t.startsWith('#')) { i++; continue; }
const ind = getIndent(l);
if (ind > metaIndent || (ind === metaIndent && t.startsWith('-'))) { i++; continue; }
break;
}
continue;
}