-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce podman machine init --root=t|f and podman machine set --roo…
…t=t|f Switch default to rootless for mac and windows Signed-off-by: Jason T. Greene <[email protected]>
- Loading branch information
Showing
10 changed files
with
318 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// +build amd64 arm64 | ||
|
||
package machine | ||
|
||
import ( | ||
"github.com/containers/common/pkg/completion" | ||
"github.com/containers/podman/v4/cmd/podman/registry" | ||
"github.com/containers/podman/v4/pkg/machine" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
setCmd = &cobra.Command{ | ||
Use: "set [options] [NAME]", | ||
Short: "Sets a virtual machine setting", | ||
Long: "Sets an updatable virtual machine setting", | ||
RunE: setMachine, | ||
Args: cobra.MaximumNArgs(1), | ||
Example: `podman machine set --root=false`, | ||
ValidArgsFunction: completion.AutocompleteNone, | ||
} | ||
) | ||
|
||
var ( | ||
setOpts = machine.SetOptions{} | ||
) | ||
|
||
func init() { | ||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Command: setCmd, | ||
Parent: machineCmd, | ||
}) | ||
flags := setCmd.Flags() | ||
|
||
rootfulFlagName := "rootful" | ||
flags.BoolVar(&setOpts.Rootful, rootfulFlagName, false, "Whether this machine should prefer rootful container execution") | ||
} | ||
|
||
func setMachine(cmd *cobra.Command, args []string) error { | ||
var ( | ||
vm machine.VM | ||
err error | ||
) | ||
|
||
vmName := defaultMachineName | ||
if len(args) > 0 && len(args[0]) > 0 { | ||
vmName = args[0] | ||
} | ||
provider := getSystemDefaultProvider() | ||
vm, err = provider.LoadVMByName(vmName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return vm.Set(vmName, setOpts) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
% podman-machine-set(1) | ||
|
||
## NAME | ||
podman\-machine\-set - Sets a virtual machine setting | ||
|
||
## SYNOPSIS | ||
**podman machine set** [*options*] [*name*] | ||
|
||
## DESCRIPTION | ||
|
||
Sets an updatable virtual machine setting. | ||
|
||
Options mirror values passed to `podman machine init`. Only a limited | ||
subset can be changed after machine initialization. | ||
|
||
## OPTIONS | ||
|
||
#### **--rootful**=*true|false* | ||
|
||
Whether this machine should prefer rootful (`true`) or rootless (`false`) | ||
container execution. This option will also update the current podman | ||
remote connection default if it is currently pointing at the specified | ||
machine name (or `podman-machine-default` if no name is specified). | ||
|
||
API forwarding, if available, will follow this setting. | ||
|
||
#### **--help** | ||
|
||
Print usage statement. | ||
|
||
## EXAMPLES | ||
|
||
To switch the default VM `podman-machine-default` from rootless to rootful: | ||
|
||
``` | ||
$ podman machine set --rootful | ||
``` | ||
|
||
or more explicitly: | ||
|
||
``` | ||
$ podman machine set --rootful=true | ||
``` | ||
|
||
To switch the default VM `podman-machine-default` from rootful to rootless: | ||
``` | ||
$ podman machine set --rootful=false | ||
``` | ||
|
||
To switch the VM `myvm` from rootless to rootful: | ||
``` | ||
$ podman machine set --rootful myvm | ||
``` | ||
|
||
## SEE ALSO | ||
**[podman(1)](podman.1.md)**, **[podman-machine(1)](podman-machine.1.md)** | ||
|
||
## HISTORY | ||
February 2022, Originally compiled by Jason Greene <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.