(msg tea.Msg)
| 465 | } |
| 466 | |
| 467 | func (m createModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 468 | switch msg := msg.(type) { |
| 469 | case createTemplatesMsg: |
| 470 | if msg.err != nil { |
| 471 | m.err = msg.err |
| 472 | return m, tea.Quit |
| 473 | } |
| 474 | m.templates = sortTemplates(msg.templates) |
| 475 | m.templatesLoaded = true |
| 476 | if len(m.templates) == 0 { |
| 477 | m.err = fmt.Errorf("no templates available") |
| 478 | return m, tea.Quit |
| 479 | } |
| 480 | // If waiting on template step with a preset, try to skip now |
| 481 | if m.step == stepTemplate && m.presets != nil && m.presets.Template != nil { |
| 482 | return m, m.trySkipCurrentStep() |
| 483 | } |
| 484 | return m, m.spinner.Tick |
| 485 | |
| 486 | case createSnapshotsMsg: |
| 487 | // Snapshots are optional, so ignore errors |
| 488 | if msg.err == nil { |
| 489 | m.snapshots = msg.snapshots |
| 490 | } |
| 491 | m.snapshotsLoaded = true |
| 492 | // If waiting on template step with a preset, try to skip now |
| 493 | if m.step == stepTemplate && m.presets != nil && m.presets.Template != nil { |
| 494 | return m, m.trySkipCurrentStep() |
| 495 | } |
| 496 | return m, m.spinner.Tick |
| 497 | |
| 498 | case createPricingMsg: |
| 499 | if msg.err == nil && msg.rates != nil { |
| 500 | m.pricing = &utils.PricingData{Rates: msg.rates} |
| 501 | } else { |
| 502 | m.pricingErr = msg.err |
| 503 | } |
| 504 | m.pricingLoaded = true |
| 505 | return m, nil |
| 506 | |
| 507 | case createSpecsMsg: |
| 508 | if msg.err != nil { |
| 509 | m.err = msg.err |
| 510 | return m, tea.Quit |
| 511 | } |
| 512 | m.specs = msg.specs |
| 513 | m.specsLoaded = true |
| 514 | // If waiting on a step that needs specs with presets, try to skip |
| 515 | if m.presets != nil { |
| 516 | return m, m.trySkipCurrentStep() |
| 517 | } |
| 518 | // Flagless flow: the user may have already advanced to a specs-dependent |
| 519 | // step while specs were loading. Initialize its cursor now that options |
| 520 | // are known (otherwise it stays at the default 0). |
| 521 | if m.step == stepGPU || m.step == stepCompute { |
| 522 | m.initStep() |
| 523 | } |
| 524 | return m, nil |
nothing calls this directly
no test coverage detected