diff --git a/api/server/backend/build/tag.go b/api/server/backend/build/tag.go index e2de4c13bb..7bd5dcdeb2 100644 --- a/api/server/backend/build/tag.go +++ b/api/server/backend/build/tag.go @@ -37,7 +37,7 @@ func (bt *Tagger) TagImages(imageID image.ID) error { for _, rt := range bt.repoAndTags { // TODO @jhowardmsft LCOW support. Will need revisiting. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } if err := bt.imageComponent.TagImageWithReference(imageID, platform, rt); err != nil { diff --git a/api/server/router/image/image_routes.go b/api/server/router/image/image_routes.go index 232d795683..9b99a585f3 100644 --- a/api/server/router/image/image_routes.go +++ b/api/server/router/image/image_routes.go @@ -101,7 +101,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite // } // valid := []string{runtime.GOOS} // - // if runtime.GOOS == "windows" && system.LCOWSupported() { + // if system.LCOWSupported() { // valid = append(valid, "linux") // } // @@ -118,7 +118,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite // return err // } platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } diff --git a/builder/dockerfile/evaluator.go b/builder/dockerfile/evaluator.go index 69e3f6d0f2..ba4315940a 100644 --- a/builder/dockerfile/evaluator.go +++ b/builder/dockerfile/evaluator.go @@ -233,7 +233,7 @@ func (s *dispatchState) beginStage(stageName string, image builder.Image) { func (s *dispatchState) setDefaultPath() { // TODO @jhowardmsft LCOW Support - This will need revisiting later platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } if system.DefaultPathEnv(platform) == "" { diff --git a/builder/dockerfile/parser/parser.go b/builder/dockerfile/parser/parser.go index 9766fbfdfe..7f07ff2150 100644 --- a/builder/dockerfile/parser/parser.go +++ b/builder/dockerfile/parser/parser.go @@ -91,8 +91,8 @@ var ( // DefaultEscapeToken is the default escape token const DefaultEscapeToken = '\\' -// DefaultPlatformToken is the platform assumed for the build if not explicitly provided -var DefaultPlatformToken = runtime.GOOS +// defaultPlatformToken is the platform assumed for the build if not explicitly provided +var defaultPlatformToken = runtime.GOOS // Directive is the structure used during a build run to hold the state of // parsing directives. @@ -119,7 +119,7 @@ func (d *Directive) setEscapeToken(s string) error { func (d *Directive) setPlatformToken(s string) error { s = strings.ToLower(s) valid := []string{runtime.GOOS} - if runtime.GOOS == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { valid = append(valid, "linux") } for _, item := range valid { @@ -154,7 +154,7 @@ func (d *Directive) possibleParserDirective(line string) error { // TODO @jhowardmsft LCOW Support: Eventually this check can be removed, // but only recognise a platform token if running in LCOW mode. - if runtime.GOOS == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { tpcMatch := tokenPlatformCommand.FindStringSubmatch(strings.ToLower(line)) if len(tpcMatch) != 0 { for i, n := range tokenPlatformCommand.SubexpNames() { @@ -177,7 +177,7 @@ func (d *Directive) possibleParserDirective(line string) error { func NewDefaultDirective() *Directive { directive := Directive{} directive.setEscapeToken(string(DefaultEscapeToken)) - directive.setPlatformToken(runtime.GOOS) + directive.setPlatformToken(defaultPlatformToken) return &directive } diff --git a/container/container.go b/container/container.go index fe050bcd17..854850f4fb 100644 --- a/container/container.go +++ b/container/container.go @@ -1038,7 +1038,7 @@ func (container *Container) CreateDaemonEnvironment(tty bool, linkedEnv []string platform = runtime.GOOS } env := []string{} - if runtime.GOOS != "windows" || (runtime.GOOS == "windows" && system.LCOWSupported() && platform == "linux") { + if runtime.GOOS != "windows" || (system.LCOWSupported() && platform == "linux") { env = []string{ "PATH=" + system.DefaultPathEnv(platform), "HOSTNAME=" + container.Config.Hostname, @@ -1052,7 +1052,6 @@ func (container *Container) CreateDaemonEnvironment(tty bool, linkedEnv []string // because the env on the container can override certain default values // we need to replace the 'env' keys where they match and append anything // else. - //return ReplaceOrAppendEnvValues(linkedEnv, container.Config.Env) - foo := ReplaceOrAppendEnvValues(env, container.Config.Env) - return foo + env = ReplaceOrAppendEnvValues(env, container.Config.Env) + return env } diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go index 75a085ef1d..92e4947e65 100644 --- a/daemon/cluster/executor/container/adapter.go +++ b/daemon/cluster/executor/container/adapter.go @@ -93,7 +93,7 @@ func (c *containerAdapter) pullImage(ctx context.Context) error { // TODO @jhowardmsft LCOW Support: This will need revisiting as // the stack is built up to include LCOW support for swarm. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } err := c.backend.PullImage(ctx, c.container.image(), "", platform, metaHeaders, authConfig, pw) diff --git a/daemon/create.go b/daemon/create.go index d47de31fa8..78070fd29d 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -82,7 +82,7 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) ( if params.Platform == "" { params.Platform = runtime.GOOS } - if params.Platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { params.Platform = "linux" } @@ -106,7 +106,7 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) ( if img != nil { if params.Platform != img.Platform() { // Ignore this in LCOW mode. @jhowardmsft TODO - This will need revisiting later. - if !(runtime.GOOS == "windows" && system.LCOWSupported()) { + if !system.LCOWSupported() { return nil, fmt.Errorf("cannot create a %s container from a %s image", params.Platform, img.Platform()) } } diff --git a/daemon/graphdriver/lcow/lcow.go b/daemon/graphdriver/lcow/lcow.go index 6bf491574a..379b7c37ce 100644 --- a/daemon/graphdriver/lcow/lcow.go +++ b/daemon/graphdriver/lcow/lcow.go @@ -118,7 +118,7 @@ func (d *Driver) terminateUvm(context string) error { // FIXME: @jhowardmsft // This isn't thread-safe yet, but will change anyway with the lifetime - // changes and multiple instances. Defering that work for now. + // changes and multiple instances. Deferring that work for now. uvm := d.config.Uvm d.config.Uvm = nil @@ -190,7 +190,6 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error { // Make sure layers are created with the correct ACL so that VMs can access them. layerPath := d.dir(id) logrus.Debugf("lcowdriver: create: id %s: creating layerPath %s", id, layerPath) - // Make sure the layers are created with the correct ACL so that VMs can access them. if err := system.MkdirAllWithACL(layerPath, 755, system.SddlNtvmAdministratorsLocalSystem); err != nil { return err } diff --git a/daemon/graphdriver/windows/windows.go b/daemon/graphdriver/windows/windows.go index a722078e35..514650aa7c 100644 --- a/daemon/graphdriver/windows/windows.go +++ b/daemon/graphdriver/windows/windows.go @@ -154,7 +154,7 @@ func (d *Driver) Status() [][2]string { } // panicIfUsedByLcow does exactly what it says. -// TODO @jhowardmsft - this is an temporary measure for the bring-up of +// TODO @jhowardmsft - this is a temporary measure for the bring-up of // Linux containers on Windows. It is a failsafe to ensure that the right // graphdriver is used. func panicIfUsedByLcow() { diff --git a/daemon/image_exporter.go b/daemon/image_exporter.go index edac775d43..a7b0be64c2 100644 --- a/daemon/image_exporter.go +++ b/daemon/image_exporter.go @@ -16,7 +16,7 @@ import ( func (daemon *Daemon) ExportImage(names []string, outStream io.Writer) error { // TODO @jhowardmsft LCOW. This will need revisiting later. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.stores[platform].referenceStore, daemon) @@ -29,7 +29,7 @@ func (daemon *Daemon) ExportImage(names []string, outStream io.Writer) error { func (daemon *Daemon) LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error { // TODO @jhowardmsft LCOW. This will need revisiting later. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } imageExporter := tarexport.NewTarExporter(daemon.stores[platform].imageStore, daemon.stores[platform].layerStore, daemon.stores[platform].referenceStore, daemon) diff --git a/daemon/image_push.go b/daemon/image_push.go index b1d15454fb..c2e5967b19 100644 --- a/daemon/image_push.go +++ b/daemon/image_push.go @@ -43,7 +43,7 @@ func (daemon *Daemon) PushImage(ctx context.Context, image, tag string, metaHead // TODO @jhowardmsft LCOW Support. This will require revisiting. For now, hard-code. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } diff --git a/daemon/images.go b/daemon/images.go index 6e29cae4d0..4baf703715 100644 --- a/daemon/images.go +++ b/daemon/images.go @@ -38,7 +38,7 @@ func (r byCreated) Less(i, j int) bool { return r[i].Created < r[j].Created } func (daemon *Daemon) Map() map[image.ID]*image.Image { // TODO @jhowardmsft LCOW. This will need work to enumerate the stores for all platforms. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } return daemon.stores[platform].imageStore.Map() @@ -53,7 +53,7 @@ func (daemon *Daemon) Images(imageFilters filters.Args, all bool, withExtraAttrs // TODO @jhowardmsft LCOW. This will need work to enumerate the stores for all platforms. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } diff --git a/daemon/info.go b/daemon/info.go index a11775c2e9..2cb3e84798 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -90,7 +90,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) { // TODO @jhowardmsft LCOW support. For now, hard-code the platform shown for the driver status p := runtime.GOOS - if p == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { p = "linux" } diff --git a/daemon/prune.go b/daemon/prune.go index 561ac1e01e..1d8686b36f 100644 --- a/daemon/prune.go +++ b/daemon/prune.go @@ -161,7 +161,7 @@ func (daemon *Daemon) VolumesPrune(ctx context.Context, pruneFilters filters.Arg func (daemon *Daemon) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error) { // TODO @jhowardmsft LCOW Support: This will need revisiting later. platform := runtime.GOOS - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index 0f3f31cf52..50257f5cb4 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -491,7 +491,7 @@ func (p *v2Puller) pullSchema1(ctx context.Context, ref reference.Named, unverif // the history does, but unfortunately that's a string, so search through // all the history until hopefully we find one which indicates the os. platform := runtime.GOOS - if runtime.GOOS == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { type config struct { Os string `json:"os,omitempty"` } diff --git a/image/store.go b/image/store.go index b215d977f8..c85f8d6830 100644 --- a/image/store.go +++ b/image/store.go @@ -3,7 +3,6 @@ package image import ( "encoding/json" "fmt" - "runtime" "strings" "sync" "time" @@ -119,8 +118,9 @@ func (is *store) Create(config []byte) (ID, error) { return "", err } + // TODO @jhowardmsft - LCOW Support. This will need revisiting. // Integrity check - ensure we are creating something for the correct platform - if runtime.GOOS == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { if strings.ToLower(img.Platform()) != strings.ToLower(is.platform) { return "", fmt.Errorf("cannot create entry for platform %q in image store for platform %q", img.Platform(), is.platform) } diff --git a/layer/layer_store.go b/layer/layer_store.go index e7c424aa92..75ac1e4f48 100644 --- a/layer/layer_store.go +++ b/layer/layer_store.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "io/ioutil" - "runtime" "strings" "sync" @@ -273,7 +272,7 @@ func (ls *layerStore) registerWithDescriptor(ts io.Reader, parent ChainID, platf var p *roLayer // Integrity check - ensure we are creating something for the correct platform - if runtime.GOOS == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { if strings.ToLower(ls.platform) != strings.ToLower(string(platform)) { return nil, fmt.Errorf("cannot create entry for platform %q in layer store for platform %q", platform, ls.platform) } diff --git a/plugin/manager.go b/plugin/manager.go index aa090f5a90..02d372741f 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -353,7 +353,7 @@ func isEqualPrivilege(a, b types.PluginPrivilege) bool { func configToRootFS(c []byte) (*image.RootFS, layer.Platform, error) { // TODO @jhowardmsft LCOW - Will need to revisit this. For now, calculate the platform. platform := layer.Platform(runtime.GOOS) - if platform == "windows" && system.LCOWSupported() { + if system.LCOWSupported() { platform = "linux" } var pluginConfig types.PluginConfig