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

Function ScriptURLExists

internal/plugins/communityscripts/scripts.go:783–816  ·  view source on GitHub ↗

ScriptURLExists checks whether the raw install script exists.

(script Script)

Source from the content-addressed store, hash-verified

781
782// ScriptURLExists checks whether the raw install script exists.
783func ScriptURLExists(script Script) (bool, error) {
784 scriptURL := RawScriptURL(script)
785 scriptURL, err := validateMetadataURL(scriptURL)
786 if err != nil {
787 return false, fmt.Errorf("invalid script URL: %w", err)
788 }
789
790 req, err := http.NewRequest(http.MethodHead, scriptURL, nil)
791 if err != nil {
792 return false, fmt.Errorf("failed to create request: %w", err)
793 }
794
795 req.Header.Add("User-Agent", "pvetui")
796
797 client := &http.Client{Timeout: 15 * time.Second}
798 resp, err := client.Do(req)
799 if err != nil {
800 return false, fmt.Errorf("failed to verify script URL: %w", err)
801 }
802
803 defer func() {
804 _ = resp.Body.Close()
805 }()
806
807 if resp.StatusCode == http.StatusNotFound {
808 return false, nil
809 }
810
811 if resp.StatusCode != http.StatusOK {
812 return false, fmt.Errorf("unexpected script URL status: %s", resp.Status)
813 }
814
815 return true, nil
816}
817
818// InstallScript installs a script on a Proxmox node via SSH.
819// Returns the remote exit code (0 on success) and any error encountered.

Callers

nothing calls this directly

Calls 3

RawScriptURLFunction · 0.85
validateMetadataURLFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected