Files
podman/pkg/machine/os/machine_os.go
Matt Heon 34166fc004 Bump Go version to v6
Tremendous amount of changes in here, but all should amount to
the same thing: changing Go import paths from v5 to v6.

Also bumped go.mod to github.com/containers/podman/v6 and updated
version to v6.0.0-dev.

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-10-23 11:00:15 -04:00

47 lines
1.2 KiB
Go

//go:build amd64 || arm64
package os
import (
"fmt"
"github.com/containers/podman/v6/pkg/machine"
"github.com/containers/podman/v6/pkg/machine/env"
"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 {
args := []string{"podman", "machine", "os", "apply", image}
if err := machine.LocalhostSSH(m.VM.SSH.RemoteUsername, m.VM.SSH.IdentityPath, m.VMName, m.VM.SSH.Port, args); err != nil {
return err
}
dirs, err := env.GetMachineDirs(m.Provider.VMType())
if err != nil {
return err
}
if m.Restart {
if err := shim.Stop(m.VM, m.Provider, dirs, false); err != nil {
return err
}
if err := shim.Start(m.VM, m.Provider, dirs, machine.StartOptions{NoInfo: true}); err != nil {
return err
}
fmt.Printf("Machine %q restarted successfully\n", m.VMName)
}
return nil
}