mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
refactor: remove docker dependency for Pid container property
This commit is contained in:
@@ -627,7 +627,7 @@ func (s *Server) CreateServiceContainer(
|
|||||||
Binds: spec.Container.Volumes,
|
Binds: spec.Container.Volumes,
|
||||||
Init: spec.Container.Init,
|
Init: spec.Container.Init,
|
||||||
Mounts: mounts,
|
Mounts: mounts,
|
||||||
PidMode: spec.Container.Pid,
|
PidMode: container.PidMode(spec.Container.PidMode),
|
||||||
PortBindings: portBindings,
|
PortBindings: portBindings,
|
||||||
Privileged: spec.Container.Privileged,
|
Privileged: spec.Container.Privileged,
|
||||||
Resources: container.Resources{
|
Resources: container.Resources{
|
||||||
|
|||||||
+3
-4
@@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
mapset "github.com/deckarep/golang-set/v2"
|
mapset "github.com/deckarep/golang-set/v2"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/container"
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/psviderski/uncloud/internal/machine/api/pb"
|
"github.com/psviderski/uncloud/internal/machine/api/pb"
|
||||||
@@ -257,8 +256,8 @@ type ContainerSpec struct {
|
|||||||
Init *bool
|
Init *bool
|
||||||
// LogDriver overrides the default logging driver for the container. Each Docker daemon can have its own default.
|
// LogDriver overrides the default logging driver for the container. Each Docker daemon can have its own default.
|
||||||
LogDriver *LogDriver
|
LogDriver *LogDriver
|
||||||
// Pid allows setting the PID name space, currently only "" or "host" is supported.
|
// PidMode sets the PID namespace mode for the container. Currently only "" or "host" is supported.
|
||||||
Pid container.PidMode
|
PidMode string
|
||||||
// Privileged gives extended privileges to the container. This is a security risk and should be used with caution.
|
// Privileged gives extended privileges to the container. This is a security risk and should be used with caution.
|
||||||
Privileged bool
|
Privileged bool
|
||||||
// PullPolicy determines when to pull the image from the registry or use the image already available in the cluster.
|
// PullPolicy determines when to pull the image from the registry or use the image already available in the cluster.
|
||||||
@@ -266,7 +265,7 @@ type ContainerSpec struct {
|
|||||||
PullPolicy string
|
PullPolicy string
|
||||||
// Resource allocation for the container.
|
// Resource allocation for the container.
|
||||||
Resources ContainerResources
|
Resources ContainerResources
|
||||||
// Namespaced kernel parameters to be set in container
|
// Namespaced kernel parameters to be set in the container.
|
||||||
Sysctls map[string]string
|
Sysctls map[string]string
|
||||||
// User overrides the default user of the image used to run the container. Format: user|UID[:group|GID].
|
// User overrides the default user of the image used to run the container. Format: user|UID[:group|GID].
|
||||||
User string
|
User string
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ func TestContainerSpec_Clone(t *testing.T) {
|
|||||||
original := ContainerSpec{
|
original := ContainerSpec{
|
||||||
CapAdd: []string{"NET_ADMIN"},
|
CapAdd: []string{"NET_ADMIN"},
|
||||||
CapDrop: []string{"ALL"},
|
CapDrop: []string{"ALL"},
|
||||||
Pid: container.PidMode("host"),
|
PidMode: "host",
|
||||||
Command: []string{"sh", "-c", "echo hello"},
|
Command: []string{"sh", "-c", "echo hello"},
|
||||||
Entrypoint: []string{"/bin/bash"},
|
Entrypoint: []string{"/bin/bash"},
|
||||||
Env: EnvVars{
|
Env: EnvVars{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func ServiceSpecFromCompose(project *types.Project, serviceName string) (api.Ser
|
|||||||
Healthcheck: healthcheckFromCompose(service.HealthCheck),
|
Healthcheck: healthcheckFromCompose(service.HealthCheck),
|
||||||
Image: service.Image,
|
Image: service.Image,
|
||||||
Init: service.Init,
|
Init: service.Init,
|
||||||
Pid: container.PidMode(service.Pid),
|
PidMode: service.Pid,
|
||||||
Privileged: service.Privileged,
|
Privileged: service.Privileged,
|
||||||
PullPolicy: pullPolicy,
|
PullPolicy: pullPolicy,
|
||||||
Resources: resourcesFromCompose(service),
|
Resources: resourcesFromCompose(service),
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ func TestServiceSpecFromCompose(t *testing.T) {
|
|||||||
"max-file": "3",
|
"max-file": "3",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Pid: "host",
|
PidMode: "host",
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
PullPolicy: api.PullPolicyAlways,
|
PullPolicy: api.PullPolicyAlways,
|
||||||
Resources: api.ContainerResources{
|
Resources: api.ContainerResources{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func TestEvalContainerSpecChange_ContainerPid(t *testing.T) {
|
|||||||
newSpec := api.ServiceSpec{
|
newSpec := api.ServiceSpec{
|
||||||
Container: api.ContainerSpec{
|
Container: api.ContainerSpec{
|
||||||
Image: "nginx:latest",
|
Image: "nginx:latest",
|
||||||
Pid: "host",
|
PidMode: "host",
|
||||||
CapAdd: []string{"NET_ADMIN"},
|
CapAdd: []string{"NET_ADMIN"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user