MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / runNodesShell

Function runNodesShell

internal/cli/nodes.go:209–253  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

207}
208
209func runNodesShell(cmd *cobra.Command, args []string) error {
210 nodeName := args[0]
211
212 session, err := initCLISession(cmd)
213 if err != nil {
214 return printError(err)
215 }
216
217 if session == nil {
218 return nil
219 }
220
221 ctx := context.Background()
222
223 node, err := session.findNodeByName(ctx, nodeName)
224 if err != nil {
225 return printError(err)
226 }
227
228 if !node.Online {
229 return printError(fmt.Errorf("node %q is offline", nodeName))
230 }
231
232 sshUser, jumpHost := session.resolveNodeSSHCreds(node)
233 if sshUser == "" {
234 return printError(fmt.Errorf("SSH user not configured; set ssh_user in config or use --ssh-user"))
235 }
236
237 keyfile := session.resolveNodeSSHKeyfile(node)
238
239 host := node.IP
240 if host == "" {
241 host = node.Name
242 }
243
244 sshArgs := ssh.BuildSSHArgs(sshUser, host, jumpHost)
245
246 fmt.Fprintf(os.Stderr, "Connecting to node %s (%s) as %s...\n", node.Name, host, sshUser)
247
248 if err := execInteractiveShell(sshArgs, keyfile); err != nil {
249 return printError(fmt.Errorf("SSH session ended with error: %w", err))
250 }
251
252 return nil
253}

Callers

nothing calls this directly

Calls 7

BuildSSHArgsFunction · 0.92
initCLISessionFunction · 0.85
printErrorFunction · 0.85
execInteractiveShellFunction · 0.85
findNodeByNameMethod · 0.80
resolveNodeSSHCredsMethod · 0.80
resolveNodeSSHKeyfileMethod · 0.80

Tested by

no test coverage detected