Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions agent/exec/dockerapi/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ func convertMount(m api.Mount) enginemount.Mount {
mount.Type = enginemount.TypeBind
case api.MountTypeVolume:
mount.Type = enginemount.TypeVolume
case api.MountTypeNamedPipe:
mount.Type = enginemount.TypeNamedPipe
}

if m.BindOptions != nil {
Expand Down
4 changes: 4 additions & 0 deletions agent/exec/dockerapi/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestVolumesAndBinds(t *testing.T) {
enginemount.Mount{Type: enginemount.TypeVolume, Source: "banana", Target: "/kerfluffle", VolumeOptions: &enginemount.VolumeOptions{NoCopy: true}}},
{"Volume with no source", api.Mount{Type: api.MountTypeVolume, Target: "/kerfluffle"},
enginemount.Mount{Type: enginemount.TypeVolume, Target: "/kerfluffle"}},
{"Named pipe using Windows format", api.Mount{Type: api.MountTypeNamedPipe, Source: `\\.\pipe\foo`, Target: `\\.\pipe\foo`},
enginemount.Mount{Type: enginemount.TypeNamedPipe, Source: `\\.\pipe\foo`, Target: `\\.\pipe\foo`}},
{"Named pipe using Unix format", api.Mount{Type: api.MountTypeNamedPipe, Source: "//./pipe/foo", Target: "//./pipe/foo"},
enginemount.Mount{Type: enginemount.TypeNamedPipe, Source: "//./pipe/foo", Target: "//./pipe/foo"}},
}

for _, c := range cases {
Expand Down
7 changes: 7 additions & 0 deletions api/api.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,13 @@ file {
66001: "MountTypeTmpfs"
}
}
value {
name: "NPIPE"
number: 3
options {
66001: "MountTypeNamedPipe"
}
}
options {
62001: 0
62023: "MountType"
Expand Down
652 changes: 328 additions & 324 deletions api/types.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ message Mount {
BIND = 0 [(gogoproto.enumvalue_customname) = "MountTypeBind"]; // Bind mount host dir
VOLUME = 1 [(gogoproto.enumvalue_customname) = "MountTypeVolume"]; // Remote storage volumes
TMPFS = 2 [(gogoproto.enumvalue_customname) = "MountTypeTmpfs"]; // Mount a tmpfs
NPIPE = 3 [(gogoproto.enumvalue_customname) = "MountTypeNamedPipe"]; // Windows named pipes
}

// Type defines the nature of the mount.
Expand Down
5 changes: 5 additions & 0 deletions cmd/swarmctl/service/flagparser/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func AddServiceFlags(flags *pflag.FlagSet) {
flags.StringSlice("bind", nil, "define a bind mount")
flags.StringSlice("volume", nil, "define a volume mount")
flags.StringSlice("tmpfs", nil, "define a tmpfs mount")
flags.StringSlice("npipe", nil, "define a npipe mount")

flags.String("log-driver", "", "specify a log driver")
flags.StringSlice("log-opt", nil, "log driver options, as key value pairs")
Expand Down Expand Up @@ -143,6 +144,10 @@ func Merge(cmd *cobra.Command, spec *api.ServiceSpec, c api.ControlClient) error
return err
}

if err := parseNpipe(flags, spec); err != nil {
return err
}

driver, err := common.ParseLogDriverFlags(flags)
if err != nil {
return err
Expand Down
37 changes: 37 additions & 0 deletions cmd/swarmctl/service/flagparser/npipe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package flagparser

import (
"fmt"
"strings"

"github.com/docker/swarmkit/api"
"github.com/spf13/pflag"
)

// parseNpipe only supports a very simple version of anonymous npipes for
// testing the most basic of data flows. Replace with a --mount flag, similar
// to what we have in docker service.
func parseNpipe(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
if flags.Changed("npipe") {
npipes, err := flags.GetStringSlice("npipe")
if err != nil {
return err
}

container := spec.Task.GetContainer()

for _, npipe := range npipes {
parts := strings.SplitN(npipe, ":", 2)
if len(parts) != 2 {
return fmt.Errorf("npipe format %q not supported", npipe)
}
container.Mounts = append(container.Mounts, api.Mount{
Type: api.MountTypeNamedPipe,
Source: parts[0],
Target: parts[1],
})
}
}

return nil
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// +build !windows

package defaults

// ControlAPISocket is the default path where clients can contact the swarmd control API.
var ControlAPISocket = "/var/run/swarmd.sock"

// EngineAddr is Docker default socket file on Linux
var EngineAddr = "unix:///var/run/docker.sock"

// StateDir is the default path to the swarmd state directory
var StateDir = "/var/lib/swarmd"
12 changes: 12 additions & 0 deletions cmd/swarmd/defaults/defaults_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build windows

package defaults

// ControlAPISocket is the default path where clients can contact the swarmd control API.
var ControlAPISocket = "//./pipe/swarmd"

// EngineAddr is Docker default named pipe on Windows
var EngineAddr = "npipe:////./pipe/docker_engine"

// StateDir is the default path to the swarmd state directory
var StateDir = `C:\ProgramData\swarmd`
2 changes: 1 addition & 1 deletion cmd/swarmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func init() {
mainCmd.Flags().StringP("log-level", "l", "info", "Log level (options \"debug\", \"info\", \"warn\", \"error\", \"fatal\", \"panic\")")
mainCmd.Flags().StringP("state-dir", "d", defaults.StateDir, "State directory")
mainCmd.Flags().StringP("join-token", "", "", "Specifies the secret token required to join the cluster")
mainCmd.Flags().String("engine-addr", "unix:///var/run/docker.sock", "Address of engine instance of agent.")
mainCmd.Flags().String("engine-addr", defaults.EngineAddr, "Address of engine instance of agent.")
mainCmd.Flags().String("hostname", "", "Override reported agent hostname")
mainCmd.Flags().String("advertise-remote-api", "", "Advertise address for remote API")
mainCmd.Flags().String("listen-remote-api", "0.0.0.0:4242", "Listen address for remote API")
Expand Down