Files
podman/pkg/machine/os/config.go
Brent Baude aba2df7517 Add podman machine os upgrade command
Implements automatic OS upgrade functionality for Podman machines that requires no user input beyond running the command. The upgrade logic automatically determines the appropriate upgrade path using a three-way comparison between client version, machine version, and OCI registry:

* When the client version is older than the machine version, no action is taken and an error is returned.
* When the client version matches the machine version, the OCI registry is queried to check for in-band updates by comparing image digests.  This handles minor, patch level, and updates oci image use cases.
* When the client version is newer than the machine version, the machine is upgraded to match the client's major.minor version.
* No manual image selection or version specification required.

The command supports dry-run mode and JSON (only) output format for automation.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-01-16 14:14:06 -06:00

49 lines
1.2 KiB
Go

//go:build amd64 || arm64
package os
import (
"context"
"github.com/blang/semver/v4"
"github.com/opencontainers/go-digest"
)
// Manager is the interface for operations on a Podman machine's OS
type Manager interface {
// Apply machine OS changes from an OCI image.
Apply(image string, opts ApplyOptions) error
// Upgrade the machine OS
Upgrade(ctx context.Context, opts UpgradeOptions) error
}
// ApplyOptions are the options for applying an image into a Podman machine VM
type ApplyOptions struct {
Image string
}
type UpgradeOptions struct {
MachineVersion semver.Version
DryRun bool
Format string
ClientVersion semver.Version
}
type Host struct {
Version semver.Version `json:"version"`
}
type Machine struct {
CurrentHash digest.Digest `json:"current_hash"`
NewHash digest.Digest `json:"new_hash"`
Version semver.Version `json:"version"`
InBandUpgradeAvailable bool `json:"inband_update_available"`
}
// UpgradeOutput is an output struct and is only exported so json tags work
// correctly
type UpgradeOutput struct {
Host Host `json:"host"`
Machine Machine `json:"machine"`
}