inferContentTypeFromURL guesses a Proxmox content type from a URL's filename extension.
(rawURL string)
| 641 | |
| 642 | // inferContentTypeFromURL guesses a Proxmox content type from a URL's filename extension. |
| 643 | func inferContentTypeFromURL(rawURL string) string { |
| 644 | lower := strings.ToLower(rawURL) |
| 645 | // Strip query string for extension matching. |
| 646 | if idx := strings.Index(lower, "?"); idx != -1 { |
| 647 | lower = lower[:idx] |
| 648 | } |
| 649 | |
| 650 | switch { |
| 651 | case strings.HasSuffix(lower, ".iso"): |
| 652 | return "iso" |
| 653 | case strings.Contains(lower, ".tar."): |
| 654 | return "vztmpl" |
| 655 | case strings.HasSuffix(lower, ".img"): |
| 656 | return "import" |
| 657 | default: |
| 658 | return "" |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | // findGuestByVMID scans all nodes for a guest with the given VMID. |
| 663 | func findGuestByVMID(client *api.Client, vmid int) (*api.VM, error) { |
no outgoing calls