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

Function deduplicateGroupVMs

pkg/api/grouped-cluster.go:55–80  ·  view source on GitHub ↗
(vms []*VM)

Source from the content-addressed store, hash-verified

53}
54
55func deduplicateGroupVMs(vms []*VM) []*VM {
56 seen := make(map[string]*VM, len(vms))
57 order := make([]string, 0, len(vms))
58
59 for _, vm := range vms {
60 if vm == nil {
61 continue
62 }
63
64 key := fmt.Sprintf("vm|%s|%d|%s", vm.Type, vm.ID, vm.Node)
65 if key == "vm||0|" {
66 key = fmt.Sprintf("vm|fallback|%s|%s|%s", vm.Name, vm.Node, vm.SourceProfile)
67 }
68
69 if _, exists := seen[key]; !exists {
70 seen[key] = vm
71 order = append(order, key)
72 }
73 }
74
75 out := make([]*VM, 0, len(order))
76 for _, key := range order {
77 out = append(out, seen[key])
78 }
79 return out
80}
81
82// GetGroupNodes retrieves nodes from all connected profiles in the group.
83// Each node's SourceProfile field is set to identify which profile it came from.

Callers 2

GetGroupVMsMethod · 0.85
TestDeduplicateGroupVMsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDeduplicateGroupVMsFunction · 0.68