github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/cmd/swarmctl/service/flagparser/npipe.go (about) 1 package flagparser 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/docker/swarmkit/api" 8 "github.com/spf13/pflag" 9 ) 10 11 // parseNpipe only supports a very simple version of anonymous npipes for 12 // testing the most basic of data flows. Replace with a --mount flag, similar 13 // to what we have in docker service. 14 func parseNpipe(flags *pflag.FlagSet, spec *api.ServiceSpec) error { 15 if flags.Changed("npipe") { 16 npipes, err := flags.GetStringSlice("npipe") 17 if err != nil { 18 return err 19 } 20 21 container := spec.Task.GetContainer() 22 23 for _, npipe := range npipes { 24 parts := strings.SplitN(npipe, ":", 2) 25 if len(parts) != 2 { 26 return fmt.Errorf("npipe format %q not supported", npipe) 27 } 28 container.Mounts = append(container.Mounts, api.Mount{ 29 Type: api.MountTypeNamedPipe, 30 Source: parts[0], 31 Target: parts[1], 32 }) 33 } 34 } 35 36 return nil 37 }