mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 19:41:17 +00:00
Docker container image update detection with full stack implementation: Backend: - Add internal/updatedetection package with types, store, registry checker, manager - Add registry checking to Docker agent (internal/dockeragent/registry.go) - Add ImageDigest and UpdateStatus fields to container reports - Add /api/infra-updates API endpoints for querying updates - Integrate with alert system - fires after 24h of pending updates Frontend: - Add UpdateBadge and UpdateIcon components for update indicators - Add updateStatus to DockerContainer TypeScript interface - Display blue update badges in Docker unified table image column - Add 'has:update' search filter support Features: - Registry digest comparison for Docker Hub, GHCR, private registries - Auth token handling for Docker Hub public images - Caching with 6h TTL (15min for errors) - Configurable alert delay via UpdateAlertDelayHours (default: 24h) - Alert metadata includes digests, pending time, image info
90 lines
3.7 KiB
Go
90 lines
3.7 KiB
Go
// Package updatedetection provides unified update detection across all Pulse-managed
|
|
// infrastructure types: Docker containers, LXC, VMs, Proxmox hosts, and Kubernetes.
|
|
package updatedetection
|
|
|
|
import "time"
|
|
|
|
// UpdateType represents the category of update
|
|
type UpdateType string
|
|
|
|
const (
|
|
UpdateTypeDockerImage UpdateType = "docker_image"
|
|
UpdateTypePackage UpdateType = "package" // apt, yum, apk
|
|
UpdateTypeProxmox UpdateType = "proxmox" // pve/pbs specific
|
|
UpdateTypeKubernetesImage UpdateType = "k8s_image"
|
|
UpdateTypeHelmChart UpdateType = "helm_chart" // future
|
|
)
|
|
|
|
// UpdateSeverity indicates how critical the update is
|
|
type UpdateSeverity string
|
|
|
|
const (
|
|
SeverityUnknown UpdateSeverity = "unknown"
|
|
SeveritySecurity UpdateSeverity = "security"
|
|
SeverityBugfix UpdateSeverity = "bugfix"
|
|
SeverityFeature UpdateSeverity = "feature"
|
|
)
|
|
|
|
// UpdateInfo represents a single available update
|
|
type UpdateInfo struct {
|
|
// Core identification
|
|
ID string `json:"id"` // Unique ID for this update
|
|
ResourceID string `json:"resourceId"` // Pulse resource ID (e.g., docker container ID)
|
|
ResourceType string `json:"resourceType"` // "docker", "lxc", "vm", "node", "k8s_pod"
|
|
ResourceName string `json:"resourceName"` // Human-readable name
|
|
HostID string `json:"hostId"` // Which host/node owns this resource
|
|
|
|
// Update specifics
|
|
Type UpdateType `json:"type"`
|
|
Severity UpdateSeverity `json:"severity,omitempty"`
|
|
|
|
// Version/Image info
|
|
CurrentVersion string `json:"currentVersion,omitempty"` // e.g., "1.2.3" or image:tag
|
|
LatestVersion string `json:"latestVersion,omitempty"` // e.g., "1.2.4" or new digest
|
|
CurrentDigest string `json:"currentDigest,omitempty"` // For container images
|
|
LatestDigest string `json:"latestDigest,omitempty"`
|
|
|
|
// Package-specific (for apt/yum updates)
|
|
PackageName string `json:"packageName,omitempty"`
|
|
PackageCount int `json:"packageCount,omitempty"` // For summary: "15 packages"
|
|
SecurityCount int `json:"securityCount,omitempty"` // Security-only count
|
|
|
|
// Timing
|
|
FirstDetected time.Time `json:"firstDetected"`
|
|
LastChecked time.Time `json:"lastChecked"`
|
|
|
|
// Additional metadata
|
|
ChangelogURL string `json:"changelogUrl,omitempty"`
|
|
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
|
Error string `json:"error,omitempty"` // If check failed
|
|
}
|
|
|
|
// UpdateSummary provides aggregated update stats for a host
|
|
type UpdateSummary struct {
|
|
HostID string `json:"hostId"`
|
|
HostName string `json:"hostName"`
|
|
TotalUpdates int `json:"totalUpdates"`
|
|
SecurityUpdates int `json:"securityUpdates"`
|
|
ContainerUpdates int `json:"containerUpdates"`
|
|
PackageUpdates int `json:"packageUpdates"`
|
|
LastChecked time.Time `json:"lastChecked"`
|
|
}
|
|
|
|
// ImageUpdateInfo contains the result of a container image update check
|
|
type ImageUpdateInfo struct {
|
|
Image string `json:"image"`
|
|
CurrentDigest string `json:"currentDigest"`
|
|
LatestDigest string `json:"latestDigest"`
|
|
UpdateAvailable bool `json:"updateAvailable"`
|
|
CheckedAt time.Time `json:"checkedAt"`
|
|
Error string `json:"error,omitempty"` // e.g., "rate limited", "auth required"
|
|
}
|
|
|
|
// ContainerUpdateStatus is included in container reports from the Docker agent
|
|
type ContainerUpdateStatus struct {
|
|
UpdateAvailable bool `json:"updateAvailable"`
|
|
CurrentDigest string `json:"currentDigest,omitempty"`
|
|
LatestDigest string `json:"latestDigest,omitempty"`
|
|
LastChecked time.Time `json:"lastChecked"`
|
|
Error string `json:"error,omitempty"` // e.g., "rate limited", "auth required"
|
|
}
|