(cmd *cobra.Command, args []string)
| 230 | } |
| 231 | |
| 232 | func runCommunityScriptsInstall(cmd *cobra.Command, args []string) error { |
| 233 | session, err := initCLISession(cmd) |
| 234 | if err != nil { |
| 235 | return printError(err) |
| 236 | } |
| 237 | if session == nil { |
| 238 | return nil |
| 239 | } |
| 240 | if err := ensureCommunityScriptsEnabled(session); err != nil { |
| 241 | return printError(err) |
| 242 | } |
| 243 | |
| 244 | nodeName, _ := cmd.Flags().GetString("node") |
| 245 | skipURLCheck, _ := cmd.Flags().GetBool("skip-url-check") |
| 246 | env, err := parseCommunityScriptEnvFlags(cmd) |
| 247 | if err != nil { |
| 248 | return printError(err) |
| 249 | } |
| 250 | nonInteractive := communityScriptNonInteractive(cmd) |
| 251 | |
| 252 | ctx := context.Background() |
| 253 | node, err := session.findNodeByName(ctx, nodeName) |
| 254 | if err != nil { |
| 255 | return printError(err) |
| 256 | } |
| 257 | if !node.Online { |
| 258 | return printError(fmt.Errorf("node %q is offline", nodeName)) |
| 259 | } |
| 260 | |
| 261 | script, err := findCommunityScript(args[0]) |
| 262 | if err != nil { |
| 263 | return printError(err) |
| 264 | } |
| 265 | if err := validateCommunityScriptInstall(script); err != nil { |
| 266 | return printError(err) |
| 267 | } |
| 268 | if !skipURLCheck { |
| 269 | ok, err := core.ScriptURLExists(script) |
| 270 | if err != nil { |
| 271 | return printError(fmt.Errorf("failed to verify script URL: %w", err)) |
| 272 | } |
| 273 | if !ok { |
| 274 | return printError(fmt.Errorf("script URL not found: %s", core.RawScriptURL(script))) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | sshUser, jumpHost := session.resolveNodeSSHCreds(node) |
| 279 | if sshUser == "" { |
| 280 | return printError(fmt.Errorf("SSH user not configured; set ssh_user in config or use --ssh-user")) |
| 281 | } |
| 282 | |
| 283 | host := node.IP |
| 284 | if host == "" { |
| 285 | host = node.Name |
| 286 | } |
| 287 | |
| 288 | var warnings []string |
| 289 | beforeVMs, beforeErr := session.getVMs(ctx) |
nothing calls this directly
no test coverage detected