Skip to content

Commit

Permalink
Add image and repo defaults for podman machine
Browse files Browse the repository at this point in the history
Signed-off-by: Jason T. Greene <[email protected]>
  • Loading branch information
n1hility committed Dec 8, 2021
1 parent b1de78a commit 1f98c17
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 8 deletions.
16 changes: 12 additions & 4 deletions docs/containers.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,22 @@ Number of CPU's a machine is created with.

The size of the disk in GB created when init-ing a podman-machine VM

**image**="testing"
**memory**=2048

Memory in MB a machine is created with.

**image**=""

Default image used when creating a new VM using `podman machine init`.
Options: `testing`, `stable`, `next`, or a custom path or download URL to an image
Options: On Linux/Mac, `testing`, `stable`, `next`. On Windows, the major
version of the OS (e.g `35`). For all platforms you can alternatively specify
a custom path or download URL to an image. The default is `testing` on
Linux/Mac, and `35` on Windows.

**memory**=2048
**user**=""

Memory in MB a machine is created with.
Username to use and create on the podman machine OS for rootless container
access. The default value is `user`. On Linux/Mac the default is`core`.

# FILES

Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ type MachineConfig struct {
Image string `toml:"image,omitempty"`
// Memory in MB a machine is created with.
Memory uint64 `toml:"memory,omitempty,omitzero"`
// Username to use for rootless podman when init-ing a podman machine VM
User string `toml:"user,omitempty"`
}

// Destination represents destination for remote service
Expand Down
9 changes: 7 additions & 2 deletions pkg/config/containers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,18 @@ default_sysctls = [
#
#disk_size=10

# Memory in MB a machine is created with.
#
#memory=2048

# The image used when creating a podman-machine VM.
#
#image = "testing"

# Memory in MB a machine is created with.
# The username to use and create on the podman machine OS for rootless
# container access.
#
#memory=2048
#user = "core"

# The [machine] table MUST be the last entry in this file.
# (Unless another table is added)
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ func defaultMachineConfig() MachineConfig {
return MachineConfig{
CPUs: 1,
DiskSize: 100,
Image: "testing",
Memory: 2048,
Image: getDefaultMachineImage(),
User: getDefaultMachineUser(),
}
}

Expand Down
11 changes: 11 additions & 0 deletions pkg/config/default_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ const (
oldMaxSize = uint64(1048576)
)

// getDefaultMachineImage returns the default machine image stream
// On Linux/Mac, this returns the FCOS stream
func getDefaultMachineImage() string {
return "testing"
}

// getDefaultMachineUser returns the user to use for rootless podman
func getDefaultMachineUser() string {
return "core"
}

// getDefaultRootlessNetwork returns the default rootless network configuration.
// It is "slirp4netns" for Linux.
func getDefaultRootlessNetwork() string {
Expand Down
14 changes: 13 additions & 1 deletion pkg/config/default_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
// +build !linux
//go:build !linux && !windows
// +build !linux,!windows

package config

// getDefaultMachineImage returns the default machine image stream
// On Linux/Mac, this returns the FCOS stream
func getDefaultMachineImage() string {
return "testing"
}

// getDefaultMachineUser returns the user to use for rootless podman
func getDefaultMachineUser() string {
return "core"
}

// getDefaultRootlessNetwork returns the default rootless network configuration.
// It is "cni" for non-Linux OSes (to better support `podman-machine` usecases).
func getDefaultRootlessNetwork() string {
Expand Down
28 changes: 28 additions & 0 deletions pkg/config/default_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package config

// getDefaultImage returns the default machine image stream
// On Windows this refers to the Fedora major release number
func getDefaultMachineImage() string {
return "35"
}

// getDefaultMachineUser returns the user to use for rootless podman
func getDefaultMachineUser() string {
return "user"
}

// getDefaultRootlessNetwork returns the default rootless network configuration.
// It is "cni" for non-Linux OSes (to better support `podman-machine` usecases).
func getDefaultRootlessNetwork() string {
return "cni"
}

// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode.
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
return false, nil
}

// getDefaultProcessLimits returns the nofile and nproc for the current process in ulimits format
func getDefaultProcessLimits() []string {
return []string{}
}

0 comments on commit 1f98c17

Please sign in to comment.