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

Function detectCreatedGuests

internal/cli/community_scripts.go:491–511  ·  view source on GitHub ↗
(before, after []*api.VM, nodeName string)

Source from the content-addressed store, hash-verified

489}
490
491func detectCreatedGuests(before, after []*api.VM, nodeName string) []guestOutput {
492 beforeGuests := map[guestIdentity]struct{}{}
493 for _, vm := range before {
494 if vm != nil {
495 beforeGuests[guestIdentityFromVM(vm)] = struct{}{}
496 }
497 }
498
499 var created []guestOutput
500 for _, vm := range after {
501 if vm == nil || vm.Node != nodeName {
502 continue
503 }
504 if _, existed := beforeGuests[guestIdentityFromVM(vm)]; existed {
505 continue
506 }
507 created = append(created, vmToGuestOutput(vm))
508 }
509
510 return created
511}
512
513type guestIdentity struct {
514 id int

Callers 2

TestDetectCreatedGuestsFunction · 0.85

Calls 2

guestIdentityFromVMFunction · 0.85
vmToGuestOutputFunction · 0.85

Tested by 1

TestDetectCreatedGuestsFunction · 0.68