daemon/container_operations_windows.go
b9e4b957
 package daemon
 
600f0ad2
 import (
bd4e8aa6
 	"fmt"
 	"io/ioutil"
 	"os"
 
600f0ad2
 	"github.com/docker/docker/container"
bd4e8aa6
 	"github.com/docker/docker/pkg/system"
600f0ad2
 	"github.com/docker/libnetwork"
bd4e8aa6
 	"github.com/pkg/errors"
1009e6a4
 	"github.com/sirupsen/logrus"
600f0ad2
 )
b9e4b957
 
6bb0d181
 func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
b9e4b957
 	return nil, nil
 }
 
e0d533b1
 func (daemon *Daemon) setupConfigDir(c *container.Container) (setupErr error) {
 	if len(c.ConfigReferences) == 0 {
 		return nil
 	}
 
eaa51928
 	localPath, err := c.ConfigsDirPath()
 	if err != nil {
 		return err
 	}
e0d533b1
 	logrus.Debugf("configs: setting up config dir: %s", localPath)
 
 	// create local config root
ed10ac6e
 	if err := system.MkdirAllWithACL(localPath, 0, system.SddlAdministratorsLocalSystem); err != nil {
e0d533b1
 		return errors.Wrap(err, "error creating config dir")
 	}
 
 	defer func() {
 		if setupErr != nil {
 			if err := os.RemoveAll(localPath); err != nil {
 				logrus.Errorf("error cleaning up config dir: %s", err)
 			}
 		}
 	}()
 
 	if c.DependencyStore == nil {
 		return fmt.Errorf("config store is not initialized")
 	}
 
 	for _, configRef := range c.ConfigReferences {
 		// TODO (ehazlett): use type switch when more are supported
 		if configRef.File == nil {
 			logrus.Error("config target type is not a file target")
 			continue
 		}
 
eaa51928
 		fPath, err := c.ConfigFilePath(*configRef)
 		if err != nil {
 			return err
 		}
e0d533b1
 
 		log := logrus.WithFields(logrus.Fields{"name": configRef.File.Name, "path": fPath})
 
 		log.Debug("injecting config")
79b940fe
 		config, err := c.DependencyStore.Configs().Get(configRef.ConfigID)
 		if err != nil {
 			return errors.Wrap(err, "unable to get config from config store")
e0d533b1
 		}
 		if err := ioutil.WriteFile(fPath, config.Spec.Data, configRef.File.Mode); err != nil {
 			return errors.Wrap(err, "error injecting config")
 		}
 	}
 
 	return nil
 }
 
3a497650
 // getSize returns real size & virtual size
bd33a99a
 func (daemon *Daemon) getSize(containerID string) (int64, int64) {
b9e4b957
 	// TODO Windows
 	return 0, 0
 }
 
6bb0d181
 func (daemon *Daemon) setupIpcDirs(container *container.Container) error {
c8291f71
 	return nil
 }
 
331c8a86
 // TODO Windows: Fix Post-TP5. This is a hack to allow docker cp to work
6bb0d181
 // against containers which have volumes. You will still be able to cp
 // to somewhere on the container drive, but not to any mounted volumes
 // inside the container. Without this fix, docker cp is broken to any
 // container which has a volume, regardless of where the file is inside the
 // container.
 func (daemon *Daemon) mountVolumes(container *container.Container) error {
c8291f71
 	return nil
 }
7d8b5fc3
 
6bb0d181
 func detachMounted(path string) error {
b3e527df
 	return nil
 }
 
bd4e8aa6
 func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
 	if len(c.SecretReferences) == 0 {
 		return nil
 	}
 
eaa51928
 	localMountPath, err := c.SecretMountPath()
 	if err != nil {
 		return err
 	}
bd4e8aa6
 	logrus.Debugf("secrets: setting up secret dir: %s", localMountPath)
 
 	// create local secret root
ed10ac6e
 	if err := system.MkdirAllWithACL(localMountPath, 0, system.SddlAdministratorsLocalSystem); err != nil {
bd4e8aa6
 		return errors.Wrap(err, "error creating secret local directory")
 	}
 
 	defer func() {
 		if setupErr != nil {
 			if err := os.RemoveAll(localMountPath); err != nil {
 				logrus.Errorf("error cleaning up secret mount: %s", err)
 			}
 		}
 	}()
 
 	if c.DependencyStore == nil {
 		return fmt.Errorf("secret store is not initialized")
 	}
 
 	for _, s := range c.SecretReferences {
 		// TODO (ehazlett): use type switch when more are supported
 		if s.File == nil {
 			logrus.Error("secret target type is not a file target")
 			continue
 		}
 
 		// secrets are created in the SecretMountPath on the host, at a
 		// single level
eaa51928
 		fPath, err := c.SecretFilePath(*s)
 		if err != nil {
 			return err
 		}
bd4e8aa6
 		logrus.WithFields(logrus.Fields{
 			"name": s.File.Name,
 			"path": fPath,
 		}).Debug("injecting secret")
79b940fe
 		secret, err := c.DependencyStore.Secrets().Get(s.SecretID)
 		if err != nil {
 			return errors.Wrap(err, "unable to get secret from secret store")
bd4e8aa6
 		}
 		if err := ioutil.WriteFile(fPath, secret.Spec.Data, s.File.Mode); err != nil {
 			return errors.Wrap(err, "error injecting secret")
 		}
 	}
 
 	return nil
 }
 
6bb0d181
 func killProcessDirectly(container *container.Container) error {
3a852d84
 	return nil
 }
e8026d8a
 
 func isLinkable(child *container.Container) bool {
 	return false
 }
1991f6eb
 
 func enableIPOnPredefinedNetwork() bool {
 	return true
 }
50f02b58
 
 func (daemon *Daemon) isNetworkHotPluggable() bool {
 	return false
 }
600f0ad2
 
 func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]libnetwork.SandboxOption) error {
 	return nil
 }
 
349913ce
 func (daemon *Daemon) initializeNetworkingPaths(container *container.Container, nc *container.Container) error {
 
 	if nc.HostConfig.Isolation.IsHyperV() {
 		return fmt.Errorf("sharing of hyperv containers network is not supported")
 	}
 
040afcce
 	container.NetworkSharedContainerID = nc.ID
349913ce
 
 	if nc.NetworkSettings != nil {
 		for n := range nc.NetworkSettings.Networks {
ccc2ed01
 			sn, err := daemon.FindNetwork(n)
349913ce
 			if err != nil {
 				continue
 			}
 
 			ep, err := nc.GetEndpointInNetwork(sn)
 			if err != nil {
 				continue
 			}
 
 			data, err := ep.DriverInfo()
 			if err != nil {
 				continue
 			}
 
 			if data["GW_INFO"] != nil {
 				gwInfo := data["GW_INFO"].(map[string]interface{})
 				if gwInfo["hnsid"] != nil {
 					container.SharedEndpointList = append(container.SharedEndpointList, gwInfo["hnsid"].(string))
 				}
 			}
 
 			if data["hnsid"] != nil {
 				container.SharedEndpointList = append(container.SharedEndpointList, data["hnsid"].(string))
 			}
 		}
 	}
 
 	return nil
600f0ad2
 }