handleRunCommand shows the command menu for the selected node.
(ctx context.Context, app *components.App, node *api.Node)
| 128 | |
| 129 | // handleRunCommand shows the command menu for the selected node. |
| 130 | func (p *Plugin) handleRunCommand(ctx context.Context, app *components.App, node *api.Node) error { |
| 131 | if app == nil { |
| 132 | return fmt.Errorf("application context unavailable") |
| 133 | } |
| 134 | |
| 135 | if node == nil { |
| 136 | return fmt.Errorf("no node selected") |
| 137 | } |
| 138 | |
| 139 | if p.runner == nil || !p.runner.Enabled() { |
| 140 | return fmt.Errorf("command runner not initialized") |
| 141 | } |
| 142 | |
| 143 | p.updateSSHClient(node) |
| 144 | |
| 145 | // Prefer IP for SSH to avoid DNS/host lookups; fall back to node name. |
| 146 | targetHost := node.IP |
| 147 | if targetHost == "" { |
| 148 | targetHost = node.Name |
| 149 | } |
| 150 | |
| 151 | // Show command menu |
| 152 | p.runner.ShowHostCommandMenu(targetHost, nil) |
| 153 | |
| 154 | return nil |
| 155 | } |
| 156 | |
| 157 | // handleRunContainerCommand shows the command menu for the selected container. |
| 158 | func (p *Plugin) handleRunContainerCommand(ctx context.Context, app *components.App, node *api.Node, guest *api.VM) error { |