(cmd *cobra.Command, args []string)
| 207 | } |
| 208 | |
| 209 | func 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 | } |
nothing calls this directly
no test coverage detected