spiegel_podman/pkg/machine/os/machine_os.go
Brent Baude 76e14f79f7 use bootc for os apply
Instead of using rpm-ostree, we now use bootc for os apply.  the
implementation is a little murky right now and will require some cleanup
to implement bootc's transports.  for now, we only support oci images
from registries.

once we have an upgrade command, the transports can be added and the
docs for apply can be ammended to be more clear.

Fixes: RUN-3836

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-01-08 13:32:39 -06:00

41 lines
1.1 KiB
Go

//go:build amd64 || arm64
package os
import (
"fmt"
"github.com/containers/podman/v6/pkg/machine"
"github.com/containers/podman/v6/pkg/machine/shim"
"github.com/containers/podman/v6/pkg/machine/vmconfigs"
)
// MachineOS manages machine OS's from outside the machine.
type MachineOS struct {
Args []string
VM *vmconfigs.MachineConfig
Provider vmconfigs.VMProvider
VMName string
Restart bool
}
// Apply applies the image by sshing into the machine and running apply from inside the VM.
func (m *MachineOS) Apply(image string, _ ApplyOptions) error {
var off bool
args := []string{"podman", "machine", "os", "apply", image}
if err := machine.LocalhostSSHShellForceTerm(m.VM.SSH.RemoteUsername, m.VM.SSH.IdentityPath, m.VMName, m.VM.SSH.Port, args); err != nil {
return err
}
if m.Restart {
if err := shim.Stop(m.VM, m.Provider, off); err != nil {
return err
}
if err := shim.Start(m.VM, m.Provider, machine.StartOptions{NoInfo: true}, &off); err != nil {
return err
}
fmt.Printf("Machine %q restarted successfully\n", m.VMName)
}
return nil
}