()
| 386 | } |
| 387 | |
| 388 | func (m modifyModel) handleEnter() (tea.Model, tea.Cmd) { |
| 389 | m.validationErr = nil |
| 390 | |
| 391 | switch m.step { |
| 392 | case modifyStepGPU: |
| 393 | gpuValues := m.specs.GPUOptions() |
| 394 | if !m.specs.IsGPUTypeAvailable(gpuValues[m.cursor]) { |
| 395 | return m, nil |
| 396 | } |
| 397 | m.resetComputeSelection() |
| 398 | m.config.GPUType = gpuValues[m.cursor] |
| 399 | m.config.GPUChanged = !strings.EqualFold(m.config.GPUType, m.currentInstance.GPUType) |
| 400 | m.step = modifyStepCompute |
| 401 | m.trySkipCurrentStep() |
| 402 | if m.quitting { |
| 403 | return m, tea.Quit |
| 404 | } |
| 405 | return m, nil |
| 406 | |
| 407 | case modifyStepCompute: |
| 408 | if m.gpuCountPhase { |
| 409 | gpuCounts := m.specs.GPUCounts(m.config.GPUType) |
| 410 | if !m.specs.IsSpecAvailable(m.config.GPUType, gpuCounts[m.cursor]) { |
| 411 | return m, nil |
| 412 | } |
| 413 | m.config.NumGPUs = gpuCounts[m.cursor] |
| 414 | m.gpuCountPhase = false |
| 415 | // Check if vCPUs preset can now be applied |
| 416 | if m.presets != nil && m.presets.VCPUs != nil { |
| 417 | if slices.Contains(m.specs.VCPUOptions(m.config.GPUType, m.config.NumGPUs), *m.presets.VCPUs) { |
| 418 | m.config.VCPUs = *m.presets.VCPUs |
| 419 | currentVCPUs, _ := strconv.Atoi(m.currentInstance.CPUCores) |
| 420 | currentNumGPUs, _ := strconv.Atoi(m.currentInstance.NumGPUs) |
| 421 | m.config.ComputeChanged = (m.config.VCPUs != currentVCPUs) || (m.config.NumGPUs != currentNumGPUs) |
| 422 | m.step = modifyStepDiskSize |
| 423 | m.trySkipCurrentStep() |
| 424 | if m.quitting { |
| 425 | return m, tea.Quit |
| 426 | } |
| 427 | return m, nil |
| 428 | } |
| 429 | } |
| 430 | m.cursor = m.getCurrentComputeCursorPosition() |
| 431 | return m, nil |
| 432 | } |
| 433 | |
| 434 | vcpuOptions := m.specs.VCPUOptions(m.config.GPUType, m.config.NumGPUs) |
| 435 | m.config.VCPUs = vcpuOptions[m.cursor] |
| 436 | currentVCPUs, _ := strconv.Atoi(m.currentInstance.CPUCores) |
| 437 | currentNumGPUs, _ := strconv.Atoi(m.currentInstance.NumGPUs) |
| 438 | m.config.ComputeChanged = (m.config.VCPUs != currentVCPUs) || (m.config.NumGPUs != currentNumGPUs) |
| 439 | m.step = modifyStepDiskSize |
| 440 | m.trySkipCurrentStep() |
| 441 | if m.quitting { |
| 442 | return m, tea.Quit |
| 443 | } |
| 444 | return m, nil |
| 445 |
no test coverage detected