()
| 1033 | } |
| 1034 | |
| 1035 | async function updateVM() { |
| 1036 | try { |
| 1037 | const vm = updateDialog.value.vm; |
| 1038 | const original = vm.configuration; |
| 1039 | const updated = updateDialog.value; |
| 1040 | |
| 1041 | const body: VmmTypes.IUpdateVmRequest = { |
| 1042 | id: vm.id, |
| 1043 | }; |
| 1044 | |
| 1045 | const fieldsToCompare = ['vcpu', 'memory', 'disk_size', 'image']; |
| 1046 | if (fieldsToCompare.some((field) => updated[field] !== original[field])) { |
| 1047 | body.vcpu = updated.vcpu; |
| 1048 | body.memory = updated.memory; |
| 1049 | body.disk_size = updated.disk_size; |
| 1050 | body.image = updated.image; |
| 1051 | } |
| 1052 | |
| 1053 | const composeWasExplicitlyUpdated = updateDialog.value.updateCompose; |
| 1054 | let composeNeedsUpdate = composeWasExplicitlyUpdated; |
| 1055 | let encryptedEnvPayload; |
| 1056 | if (updateDialog.value.resetSecrets) { |
| 1057 | const keyResponse = await vmmRpc.getAppEnvEncryptPubKey({ app_id: hexToBytes(vm.app_id || '') }); |
| 1058 | encryptedEnvPayload = await encryptEnvWithKey(updateDialog.value.encryptedEnvs, keyResponse.public_key); |
| 1059 | composeNeedsUpdate = true; |
| 1060 | } |
| 1061 | body.compose_file = composeNeedsUpdate ? await makeUpdateComposeFile() : undefined; |
| 1062 | body.encrypted_env = encryptedEnvPayload; |
| 1063 | body.user_config = updated.user_config; |
| 1064 | body.update_ports = true; |
| 1065 | body.ports = normalizePorts(updated.ports); |
| 1066 | body.gpus = updateDialog.value.updateGpuConfig ? configGpu(updated, true) : undefined; |
| 1067 | |
| 1068 | await vmmRpc.updateVm(body); |
| 1069 | updateDialog.value.encryptedEnvs = []; |
| 1070 | updateDialog.value.show = false; |
| 1071 | if (composeWasExplicitlyUpdated) { |
| 1072 | updateMessage.value = '✅ Compose file updated!'; |
| 1073 | } |
| 1074 | loadVMList(); |
| 1075 | } catch (error) { |
| 1076 | recordError('error upgrading VM', error); |
| 1077 | alert('failed to upgrade VM'); |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | function getKeyProvider(vm: VmListItem): KeyProviderKind { |
| 1082 | if (vm.appCompose?.key_provider) { |
nothing calls this directly
no test coverage detected