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

Function runStorageDownloadOCI

internal/cli/storage.go:644–696  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

642}
643
644func runStorageDownloadOCI(cmd *cobra.Command, args []string) error {
645 ctx := context.Background()
646 nodeName := args[0]
647 storageName := args[1]
648 reference := args[2]
649
650 session, err := initCLISession(cmd)
651 if err != nil {
652 return printError(err)
653 }
654
655 if session == nil {
656 return nil
657 }
658
659 client, err := session.clientForNode(ctx, nodeName)
660 if err != nil {
661 return printError(err)
662 }
663
664 upid, err := client.PullStorageOCIImage(nodeName, storageName, api.StorageOCIPullOptions{
665 Reference: reference,
666 })
667 if err != nil {
668 return printError(fmt.Errorf("failed to pull OCI image: %w", err))
669 }
670
671 out := storageTaskOutput{
672 Node: nodeName,
673 Storage: storageName,
674 Reference: reference,
675 UPID: upid,
676 Status: "running",
677 }
678
679 if getNoWait(cmd) {
680 return printJSON(out)
681 }
682
683 exitStatus, waitErr := waitForTask(ctx, client, nodeName, upid, "pull OCI image")
684 out.Status = "complete"
685 out.ExitStatus = exitStatus
686
687 if err := printJSON(out); err != nil {
688 return err
689 }
690
691 if waitErr != nil {
692 return waitErr
693 }
694
695 return nil
696}
697
698// ── storage restore ───────────────────────────────────────────────────────────
699

Callers

nothing calls this directly

Calls 7

initCLISessionFunction · 0.85
printErrorFunction · 0.85
getNoWaitFunction · 0.85
printJSONFunction · 0.85
waitForTaskFunction · 0.85
clientForNodeMethod · 0.80
PullStorageOCIImageMethod · 0.80

Tested by

no test coverage detected