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

Method GetNodeUpdates

pkg/api/node_updates.go:19–48  ·  view source on GitHub ↗

GetNodeUpdates retrieves the list of available updates for a specific node.

(nodeName string)

Source from the content-addressed store, hash-verified

17
18// GetNodeUpdates retrieves the list of available updates for a specific node.
19func (c *Client) GetNodeUpdates(nodeName string) ([]NodeUpdate, error) {
20 var res map[string]interface{}
21
22 // /nodes/{node}/apt/update returns the list of upgradable packages (from `apt list --upgradable`).
23 if err := c.GetWithCache(fmt.Sprintf("/nodes/%s/apt/update", nodeName), &res, NodeDataTTL); err != nil {
24 return nil, fmt.Errorf("failed to get node updates: %w", err)
25 }
26
27 data, ok := res["data"].([]interface{})
28 if !ok {
29 return nil, fmt.Errorf("invalid updates response format")
30 }
31
32 var updates []NodeUpdate
33 for _, item := range data {
34 if uData, ok := item.(map[string]interface{}); ok {
35 update := NodeUpdate{
36 Package: getString(uData, "Package"),
37 Title: getString(uData, "Title"),
38 Version: getString(uData, "Version"),
39 OldVersion: getString(uData, "OldVersion"),
40 Arch: getString(uData, "Arch"),
41 Description: getString(uData, "Description"),
42 Origin: getString(uData, "Origin"),
43 }
44 updates = append(updates, update)
45 }
46 }
47 return updates, nil
48}

Callers 3

RefreshNodeDataMethod · 0.95
TestGetNodeUpdatesFunction · 0.95

Calls 2

GetWithCacheMethod · 0.95
getStringFunction · 0.85

Tested by 1

TestGetNodeUpdatesFunction · 0.76