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

Method PullStorageOCIImage

pkg/api/storage_content.go:147–183  ·  view source on GitHub ↗

PullStorageOCIImage queues an OCI registry pull task and returns the task UPID.

(nodeName, storageName string, options StorageOCIPullOptions)

Source from the content-addressed store, hash-verified

145
146// PullStorageOCIImage queues an OCI registry pull task and returns the task UPID.
147func (c *Client) PullStorageOCIImage(nodeName, storageName string, options StorageOCIPullOptions) (string, error) {
148 if strings.TrimSpace(nodeName) == "" {
149 return "", fmt.Errorf("node name is required")
150 }
151 if strings.TrimSpace(storageName) == "" {
152 return "", fmt.Errorf("storage name is required")
153 }
154 if strings.TrimSpace(options.Reference) == "" {
155 return "", fmt.Errorf("reference is required")
156 }
157
158 path := fmt.Sprintf("/nodes/%s/storage/%s/oci-registry-pull", nodeName, storageName)
159 data := map[string]interface{}{
160 "reference": strings.TrimSpace(options.Reference),
161 }
162 if strings.TrimSpace(options.Filename) != "" {
163 data["filename"] = strings.TrimSpace(options.Filename)
164 }
165
166 var res map[string]interface{}
167 if err := c.PostWithResponse(path, data, &res); err != nil {
168 return "", fmt.Errorf("failed to pull OCI image on %s/%s: %w", nodeName, storageName, err)
169 }
170
171 if errMsg, ok := res["error"].(string); ok && errMsg != "" {
172 return "", fmt.Errorf("OCI pull failed: %s", errMsg)
173 }
174
175 upid, ok := res["data"].(string)
176 if !ok || !strings.HasPrefix(upid, "UPID:") {
177 return "", fmt.Errorf("failed to get OCI pull task ID")
178 }
179
180 c.ClearAPICache()
181
182 return upid, nil
183}
184
185// ApplianceTemplate represents an available appliance template from the Proxmox catalog.
186type ApplianceTemplate struct {

Callers 3

TestPVEMockAPIFunction · 0.95
runStorageDownloadOCIFunction · 0.80
enqueueStorageOCIPullMethod · 0.80

Calls 2

PostWithResponseMethod · 0.95
ClearAPICacheMethod · 0.95

Tested by 1

TestPVEMockAPIFunction · 0.76