From 1611d6e6b411048b2f003af17694adadba4621b8 Mon Sep 17 00:00:00 2001 From: "Jason T. Greene" Date: Fri, 15 Apr 2022 17:10:23 -0500 Subject: [PATCH] Add MachineType specification Signed-off-by: Jason T. Greene --- docs/containers.conf.5.md | 6 ++++++ pkg/config/config.go | 4 ++++ pkg/config/config_local_test.go | 12 ++++++++++++ pkg/config/default.go | 1 + pkg/config/testdata/containers_default.conf | 1 + 5 files changed, 24 insertions(+) diff --git a/docs/containers.conf.5.md b/docs/containers.conf.5.md index affcc4595..aa3bc84dd 100644 --- a/docs/containers.conf.5.md +++ b/docs/containers.conf.5.md @@ -490,6 +490,12 @@ Indicates if Podman is running inside a VM via Podman Machine. Podman uses this value to do extra setup around networking from the container inside the VM to to host. +**machine_host_type**="" + +Indicates the type of machine if Podman is running inside a podman machine +instance. The value is only relevant if machine_enabled is true. The default +value (empty string) indicates the machine host type is unknown. + **multi_image_archive**=false Allows for creating archives (e.g., tarballs) with more than one image. Some container engines, such as Podman, interpret additional arguments as tags for one image and hence do not store more than one image. The default behavior can be altered with this option. diff --git a/pkg/config/config.go b/pkg/config/config.go index 8d2839cc7..72ce60e4b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -304,6 +304,10 @@ type EngineConfig struct { // MachineEnabled indicates if Podman is running in a podman-machine VM MachineEnabled bool `toml:"machine_enabled,omitempty"` + // MachineHostType indicates the type of machine if Podman is running inside a + // podman-machine instance + MachineHostType string `toml:"machine_host_type,omitempty"` + // MultiImageArchive - if true, the container engine allows for storing // archives (e.g., of the docker-archive transport) with multiple // images. By default, Podman creates single-image archives. diff --git a/pkg/config/config_local_test.go b/pkg/config/config_local_test.go index 59e565203..7c0780446 100644 --- a/pkg/config/config_local_test.go +++ b/pkg/config/config_local_test.go @@ -376,6 +376,18 @@ var _ = Describe("Config Local", func() { gomega.Expect(config2.Engine.MachineEnabled).To(gomega.Equal(true)) }) + It("Set Machine Type", func() { + // Given + config, err := NewConfig("") + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(config.Engine.MachineHostType).To(gomega.Equal("")) + // When + config2, err := NewConfig("testdata/containers_default.conf") + // Then + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(config2.Engine.MachineHostType).To(gomega.Equal("wsl")) + }) + It("default netns", func() { // Given config, err := NewConfig("") diff --git a/pkg/config/default.go b/pkg/config/default.go index aa7ce1475..822e61331 100644 --- a/pkg/config/default.go +++ b/pkg/config/default.go @@ -381,6 +381,7 @@ func defaultConfigFromMemory() (*EngineConfig, error) { // constants. c.LockType = "shm" c.MachineEnabled = false + c.MachineHostType = "" c.ChownCopiedFiles = true return c, nil diff --git a/pkg/config/testdata/containers_default.conf b/pkg/config/testdata/containers_default.conf index 25f8a1c54..ea1380742 100644 --- a/pkg/config/testdata/containers_default.conf +++ b/pkg/config/testdata/containers_default.conf @@ -156,6 +156,7 @@ env = ["super=duper", "foo=bar"] tmp_dir = "/run/libpod" machine_enabled = true +machine_type = "wsl" # Whether to use chroot instead of pivot_root in the runtime no_pivot_root = false