mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 15:01:46 +00:00
fix: preserve YAML device parameters on config editing (#487)
Signed-off-by: Caio Torres <caio.torres@suse.com>
This commit is contained in:
parent
775330d829
commit
22c99211f1
@ -767,6 +767,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const specDisks = this.spec?.template?.spec?.domain?.devices?.disks;
|
||||||
|
const mergedDisks = this.mergeDeviceList(specDisks, disks);
|
||||||
|
|
||||||
let spec = {
|
let spec = {
|
||||||
...this.spec,
|
...this.spec,
|
||||||
runStrategy: this.runStrategy,
|
runStrategy: this.runStrategy,
|
||||||
@ -789,7 +792,7 @@ export default {
|
|||||||
...this.spec.template?.spec?.domain,
|
...this.spec.template?.spec?.domain,
|
||||||
devices: {
|
devices: {
|
||||||
...this.spec.template?.spec?.domain?.devices,
|
...this.spec.template?.spec?.domain?.devices,
|
||||||
disks,
|
disks: mergedDisks,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
volumes,
|
volumes,
|
||||||
@ -888,13 +891,16 @@ export default {
|
|||||||
interfaces.push(_interface);
|
interfaces.push(_interface);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const specInterfaces = this.spec?.template?.spec?.domain?.devices?.interfaces;
|
||||||
|
const mergedInterfaces = this.mergeDeviceList(specInterfaces, interfaces);
|
||||||
|
|
||||||
const spec = {
|
const spec = {
|
||||||
...this.spec.template.spec,
|
...this.spec.template.spec,
|
||||||
domain: {
|
domain: {
|
||||||
...this.spec.template.spec.domain,
|
...this.spec.template.spec.domain,
|
||||||
devices: {
|
devices: {
|
||||||
...this.spec.template.spec.domain.devices,
|
...this.spec.template.spec.domain.devices,
|
||||||
interfaces,
|
interfaces: mergedInterfaces,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
networks
|
networks
|
||||||
@ -1543,6 +1549,23 @@ export default {
|
|||||||
this.refreshYamlEditor();
|
this.refreshYamlEditor();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mergeDeviceList(specDeviceList, deviceList) {
|
||||||
|
if (!specDeviceList || specDeviceList.length === 0) {
|
||||||
|
return deviceList;
|
||||||
|
}
|
||||||
|
const specDeviceMap = new Map(specDeviceList.map((device) => [device.name, device]));
|
||||||
|
|
||||||
|
return deviceList.map((device) => {
|
||||||
|
const specDevice = specDeviceMap.get(device.name);
|
||||||
|
|
||||||
|
if (specDevice) {
|
||||||
|
return { ...specDevice, ...device };
|
||||||
|
}
|
||||||
|
|
||||||
|
return device;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
refreshYamlEditor() {
|
refreshYamlEditor() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.yamlEditor?.updateValue();
|
this.$refs.yamlEditor?.updateValue();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user