mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 13:11:43 +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 = {
|
||||
...this.spec,
|
||||
runStrategy: this.runStrategy,
|
||||
@ -789,7 +792,7 @@ export default {
|
||||
...this.spec.template?.spec?.domain,
|
||||
devices: {
|
||||
...this.spec.template?.spec?.domain?.devices,
|
||||
disks,
|
||||
disks: mergedDisks,
|
||||
},
|
||||
},
|
||||
volumes,
|
||||
@ -888,13 +891,16 @@ export default {
|
||||
interfaces.push(_interface);
|
||||
});
|
||||
|
||||
const specInterfaces = this.spec?.template?.spec?.domain?.devices?.interfaces;
|
||||
const mergedInterfaces = this.mergeDeviceList(specInterfaces, interfaces);
|
||||
|
||||
const spec = {
|
||||
...this.spec.template.spec,
|
||||
domain: {
|
||||
...this.spec.template.spec.domain,
|
||||
devices: {
|
||||
...this.spec.template.spec.domain.devices,
|
||||
interfaces,
|
||||
interfaces: mergedInterfaces,
|
||||
},
|
||||
},
|
||||
networks
|
||||
@ -1543,6 +1549,23 @@ export default {
|
||||
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() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.yamlEditor?.updateValue();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user