(cmd *cobra.Command, nameOrSlug string)
| 346 | } |
| 347 | |
| 348 | func buildCommunityScriptPlan(cmd *cobra.Command, nameOrSlug string) (*communityScriptPlanOutput, error) { |
| 349 | session, err := initCLISession(cmd) |
| 350 | if err != nil { |
| 351 | return nil, err |
| 352 | } |
| 353 | if session == nil { |
| 354 | return nil, nil |
| 355 | } |
| 356 | if err := ensureCommunityScriptsEnabled(session); err != nil { |
| 357 | return nil, err |
| 358 | } |
| 359 | |
| 360 | nodeName, _ := cmd.Flags().GetString("node") |
| 361 | env, err := parseCommunityScriptEnvFlags(cmd) |
| 362 | if err != nil { |
| 363 | return nil, err |
| 364 | } |
| 365 | |
| 366 | ctx := context.Background() |
| 367 | node, err := session.findNodeByName(ctx, nodeName) |
| 368 | if err != nil { |
| 369 | return nil, err |
| 370 | } |
| 371 | if !node.Online { |
| 372 | return nil, fmt.Errorf("node %q is offline", nodeName) |
| 373 | } |
| 374 | |
| 375 | script, err := findCommunityScript(nameOrSlug) |
| 376 | if err != nil { |
| 377 | return nil, err |
| 378 | } |
| 379 | if err := validateCommunityScriptInstall(script); err != nil { |
| 380 | return nil, err |
| 381 | } |
| 382 | |
| 383 | sshUser, _ := session.resolveNodeSSHCreds(node) |
| 384 | if sshUser == "" { |
| 385 | return nil, fmt.Errorf("SSH user not configured; set ssh_user in config or use --ssh-user") |
| 386 | } |
| 387 | |
| 388 | host := node.IP |
| 389 | if host == "" { |
| 390 | host = node.Name |
| 391 | } |
| 392 | |
| 393 | redactedEnv := redactCommunityScriptEnv(env) |
| 394 | preset := "" |
| 395 | if communityScriptNonInteractive(cmd) { |
| 396 | preset = "default" |
| 397 | } |
| 398 | |
| 399 | remoteCmd, err := core.BuildRemoteInstallCommand(sshUser, script, redactedEnv, preset) |
| 400 | if err != nil { |
| 401 | return nil, err |
| 402 | } |
| 403 | |
| 404 | return &communityScriptPlanOutput{ |
| 405 | Node: node.Name, |
no test coverage detected