mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Move some logic of setRootful
to a common file
Moves most of the logic of `setRootful` to the common file `pkg/machine/machine_common.go`. Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
This commit is contained in:
@ -692,22 +692,10 @@ func (m *HyperVMachine) writeConfig() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *HyperVMachine) setRootful(rootful bool) error {
|
func (m *HyperVMachine) setRootful(rootful bool) error {
|
||||||
changeCon, err := machine.AnyConnectionDefault(m.Name, m.Name+"-root")
|
if err := machine.SetRootful(rootful, m.Name, m.Name+"-root"); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if changeCon {
|
|
||||||
newDefault := m.Name
|
|
||||||
if rootful {
|
|
||||||
newDefault += "-root"
|
|
||||||
}
|
|
||||||
err := machine.ChangeDefault(newDefault)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m.HostUser.Modified = true
|
m.HostUser.Modified = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -122,3 +122,24 @@ func WaitAPIAndPrintInfo(forwardState APIForwardingState, name, helper, forwardS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRootful modifies the machine's default connection to be either rootful or
|
||||||
|
// rootless
|
||||||
|
func SetRootful(rootful bool, name, rootfulName string) error {
|
||||||
|
changeCon, err := AnyConnectionDefault(name, rootfulName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if changeCon {
|
||||||
|
newDefault := name
|
||||||
|
if rootful {
|
||||||
|
newDefault += "-root"
|
||||||
|
}
|
||||||
|
err := ChangeDefault(newDefault)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -1607,22 +1607,10 @@ func (v *MachineVM) resizeDisk(diskSize uint64, oldSize uint64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *MachineVM) setRootful(rootful bool) error {
|
func (v *MachineVM) setRootful(rootful bool) error {
|
||||||
changeCon, err := machine.AnyConnectionDefault(v.Name, v.Name+"-root")
|
if err := machine.SetRootful(rootful, v.Name, v.Name+"-root"); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if changeCon {
|
|
||||||
newDefault := v.Name
|
|
||||||
if rootful {
|
|
||||||
newDefault += "-root"
|
|
||||||
}
|
|
||||||
err := machine.ChangeDefault(newDefault)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
v.HostUser.Modified = true
|
v.HostUser.Modified = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1525,22 +1525,10 @@ func getMem(vm *MachineVM) (uint64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *MachineVM) setRootful(rootful bool) error {
|
func (v *MachineVM) setRootful(rootful bool) error {
|
||||||
changeCon, err := machine.AnyConnectionDefault(v.Name, v.Name+"-root")
|
if err := machine.SetRootful(rootful, v.Name, v.Name+"-root"); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if changeCon {
|
|
||||||
newDefault := v.Name
|
|
||||||
if rootful {
|
|
||||||
newDefault += "-root"
|
|
||||||
}
|
|
||||||
err := machine.ChangeDefault(newDefault)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dist := toDist(v.Name)
|
dist := toDist(v.Name)
|
||||||
return v.setupPodmanDockerSock(dist, rootful)
|
return v.setupPodmanDockerSock(dist, rootful)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user