GetScriptsByCategory returns scripts for a specific category.
(category string)
| 536 | |
| 537 | // GetScriptsByCategory returns scripts for a specific category. |
| 538 | func GetScriptsByCategory(category string) ([]Script, error) { |
| 539 | allScripts, err := FetchScripts() |
| 540 | if err != nil { |
| 541 | return nil, err |
| 542 | } |
| 543 | |
| 544 | // Filter scripts by category |
| 545 | var categoryScripts []Script |
| 546 | |
| 547 | for _, script := range allScripts { |
| 548 | // If the script path starts with the category name or the type matches |
| 549 | if strings.HasPrefix(script.ScriptPath, category+"/") || script.Type == category { |
| 550 | categoryScripts = append(categoryScripts, script) |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | if len(categoryScripts) == 0 { |
| 555 | return nil, fmt.Errorf("no scripts found for category: %s", category) |
| 556 | } |
| 557 | |
| 558 | return categoryScripts, nil |
| 559 | } |
| 560 | |
| 561 | // InstallScript installs a script on a Proxmox node interactively. |
| 562 | func validateScriptPath(scriptPath string) error { |
nothing calls this directly
no test coverage detected