github.com/gunjan5/docker@v1.8.2/daemon/execdriver/windows/windows.go (about) 1 // +build windows 2 3 package windows 4 5 import ( 6 "fmt" 7 "strings" 8 "sync" 9 10 "github.com/Sirupsen/logrus" 11 "github.com/docker/docker/autogen/dockerversion" 12 "github.com/docker/docker/daemon/execdriver" 13 "github.com/docker/docker/pkg/parsers" 14 ) 15 16 // This is a daemon development variable only and should not be 17 // used for running production containers on Windows. 18 var dummyMode bool 19 20 // This allows the daemon to terminate containers rather than shutdown 21 var terminateMode bool 22 23 var ( 24 DriverName = "Windows 1854" 25 Version = dockerversion.VERSION + " " + dockerversion.GITCOMMIT 26 ) 27 28 type activeContainer struct { 29 command *execdriver.Command 30 } 31 32 type driver struct { 33 root string 34 initPath string 35 activeContainers map[string]*activeContainer 36 sync.Mutex 37 } 38 39 func (d *driver) Name() string { 40 return fmt.Sprintf("%s %s", DriverName, Version) 41 } 42 43 func NewDriver(root, initPath string, options []string) (*driver, error) { 44 45 for _, option := range options { 46 key, val, err := parsers.ParseKeyValueOpt(option) 47 if err != nil { 48 return nil, err 49 } 50 key = strings.ToLower(key) 51 switch key { 52 53 case "dummy": 54 switch val { 55 case "1": 56 dummyMode = true 57 logrus.Warn("Using dummy mode in Windows exec driver. This is for development use only!") 58 } 59 60 case "terminate": 61 switch val { 62 case "1": 63 terminateMode = true 64 logrus.Warn("Using terminate mode in Windows exec driver. This is for testing purposes only.") 65 } 66 67 default: 68 return nil, fmt.Errorf("Unrecognised exec driver option %s\n", key) 69 } 70 } 71 72 return &driver{ 73 root: root, 74 initPath: initPath, 75 activeContainers: make(map[string]*activeContainer), 76 }, nil 77 } 78 79 // setupEnvironmentVariables convert a string array of environment variables 80 // into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc. 81 func setupEnvironmentVariables(a []string) map[string]string { 82 r := make(map[string]string) 83 for _, s := range a { 84 arr := strings.Split(s, "=") 85 if len(arr) == 2 { 86 r[arr[0]] = arr[1] 87 } 88 } 89 return r 90 }