MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / runModify

Function runModify

cmd/modify.go:47–290  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

45}
46
47func runModify(cmd *cobra.Command, args []string) error {
48 client, err := getAuthenticatedClient()
49 if err != nil {
50 return err
51 }
52
53 var (
54 specs *utils.SpecStore
55 specsErr error
56 instances []api.Instance
57 instErr error
58 )
59 if err := tui.RunWithBusySpinner("Fetching instances...", os.Stdout, func() error {
60 var wg sync.WaitGroup
61 wg.Add(2)
62 go func() {
63 defer wg.Done()
64 specs, specsErr = utils.FetchSpecStore(client)
65 }()
66 go func() {
67 defer wg.Done()
68 instances, instErr = client.ListInstances()
69 }()
70 wg.Wait()
71 if specsErr != nil {
72 return specsErr
73 }
74 if instErr != nil {
75 return fmt.Errorf("failed to fetch instances: %w", instErr)
76 }
77 return nil
78 }); err != nil {
79 return err
80 }
81
82 if len(instances) == 0 {
83 PrintWarningSimple("No instances found. Use 'tnr create' to create a Thunder Compute instance.")
84 return nil
85 }
86
87 interactive := tui.IsInteractive() && !JSONOutput
88
89 var selectedInstance *api.Instance
90
91 // Determine which instance to modify
92 if len(args) == 0 {
93 if !interactive {
94 return usageErr("instance ID required in non-interactive mode")
95 }
96 // No argument - show interactive selector
97 selectedInstance, err = tui.RunModifyInstanceSelector(client, instances)
98 if err != nil {
99 if errors.Is(err, tui.ErrCancelled) {
100 PrintWarningSimple("User cancelled modification process")
101 return nil
102 }
103 return err
104 }

Callers 1

modify.goFile · 0.85

Calls 15

RunWithBusySpinnerFunction · 0.92
FetchSpecStoreFunction · 0.92
IsInteractiveFunction · 0.92
RunModifyInteractiveFunction · 0.92
RunModifyHybridFunction · 0.92
CalculateHourlyPriceFunction · 0.92
FormatPriceFunction · 0.92
NewProgressModelFunction · 0.92
getAuthenticatedClientFunction · 0.85
PrintWarningSimpleFunction · 0.85
usageErrFunction · 0.85

Tested by

no test coverage detected