Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

758 B
Raw Blame
import type { GuestMetadata } from '@/api/guestMetadata';
import type { WorkloadGuest } from '@/types/workloads';
import { getWorkloadMetadataIdCandidates } from '@/utils/workloads';

export type WorkloadGuestMetadataMap = Record<string, GuestMetadata>;

/**
 * Saved metadata for a workload row. Stable identities win over the legacy
 * instance:node:vmid key that v5 data volumes still carry.
 */
export const getWorkloadGuestMetadataRecord = (
  guest: WorkloadGuest,
  byId: WorkloadGuestMetadataMap,
): GuestMetadata | undefined => {
  for (const metadataId of getWorkloadMetadataIdCandidates(guest)) {
    if (metadataId && byId[metadataId]) {
      return byId[metadataId];
    }
  }
  return byId[`${guest.instance}:${guest.node}:${guest.vmid}`];
};