From 84450b72cd73161449bae16b8ad0010fcc4a07eb Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 11 Nov 2016 15:15:10 +0100 Subject: [PATCH] Add support for stdin_open in composefile v3 Signed-off-by: Vincent Demeester --- api/types/swarm/container.go | 1 + cli/command/stack/deploy.go | 1 + daemon/cluster/convert/container.go | 50 ++++++++++--------- .../cluster/executor/container/container.go | 1 + 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/api/types/swarm/container.go b/api/types/swarm/container.go index 0db5cbcb81..4ab476ccc3 100644 --- a/api/types/swarm/container.go +++ b/api/types/swarm/container.go @@ -33,6 +33,7 @@ type ContainerSpec struct { User string `json:",omitempty"` Groups []string `json:",omitempty"` TTY bool `json:",omitempty"` + OpenStdin bool `json:",omitempty"` Mounts []mount.Mount `json:",omitempty"` StopGracePeriod *time.Duration `json:",omitempty"` Healthcheck *container.HealthConfig `json:",omitempty"` diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index 94ef6bac2c..147df1a0b9 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -505,6 +505,7 @@ func convertService( Mounts: mounts, StopGracePeriod: service.StopGracePeriod, TTY: service.Tty, + OpenStdin: service.StdinOpen, }, Resources: resources, RestartPolicy: restartPolicy, diff --git a/daemon/cluster/convert/container.go b/daemon/cluster/convert/container.go index ebd80d09e6..eb1a84c9c4 100644 --- a/daemon/cluster/convert/container.go +++ b/daemon/cluster/convert/container.go @@ -14,18 +14,19 @@ import ( func containerSpecFromGRPC(c *swarmapi.ContainerSpec) types.ContainerSpec { containerSpec := types.ContainerSpec{ - Image: c.Image, - Labels: c.Labels, - Command: c.Command, - Args: c.Args, - Hostname: c.Hostname, - Env: c.Env, - Dir: c.Dir, - User: c.User, - Groups: c.Groups, - TTY: c.TTY, - Hosts: c.Hosts, - Secrets: secretReferencesFromGRPC(c.Secrets), + Image: c.Image, + Labels: c.Labels, + Command: c.Command, + Args: c.Args, + Hostname: c.Hostname, + Env: c.Env, + Dir: c.Dir, + User: c.User, + Groups: c.Groups, + TTY: c.TTY, + OpenStdin: c.OpenStdin, + Hosts: c.Hosts, + Secrets: secretReferencesFromGRPC(c.Secrets), } if c.DNSConfig != nil { @@ -123,18 +124,19 @@ func secretReferencesFromGRPC(sr []*swarmapi.SecretReference) []*types.SecretRef func containerToGRPC(c types.ContainerSpec) (*swarmapi.ContainerSpec, error) { containerSpec := &swarmapi.ContainerSpec{ - Image: c.Image, - Labels: c.Labels, - Command: c.Command, - Args: c.Args, - Hostname: c.Hostname, - Env: c.Env, - Dir: c.Dir, - User: c.User, - Groups: c.Groups, - TTY: c.TTY, - Hosts: c.Hosts, - Secrets: secretReferencesToGRPC(c.Secrets), + Image: c.Image, + Labels: c.Labels, + Command: c.Command, + Args: c.Args, + Hostname: c.Hostname, + Env: c.Env, + Dir: c.Dir, + User: c.User, + Groups: c.Groups, + TTY: c.TTY, + OpenStdin: c.OpenStdin, + Hosts: c.Hosts, + Secrets: secretReferencesToGRPC(c.Secrets), } if c.DNSConfig != nil { diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index bed613ca8e..88a80e4b7e 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -185,6 +185,7 @@ func (c *containerConfig) config() *enginecontainer.Config { config := &enginecontainer.Config{ Labels: c.labels(), Tty: c.spec().TTY, + OpenStdin: c.spec().OpenStdin, User: c.spec().User, Env: c.spec().Env, Hostname: c.spec().Hostname,