1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

pkg/containerfs: Trim away Driver interface part 1

The Driver interface was required for Linux Containers on Windows, which
is no longer supported.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider 2022-09-22 19:49:22 -04:00
parent 8520b322aa
commit 4d48c00f94
3 changed files with 5 additions and 19 deletions

View file

@ -3,6 +3,7 @@ package remotecontext // import "github.com/docker/docker/builder/remotecontext"
import (
"encoding/hex"
"os"
"runtime"
"strings"
"github.com/docker/docker/builder"
@ -88,7 +89,7 @@ func (c *lazySource) prepareHash(relPath string, fi os.FileInfo) (string, error)
// handle UUID paths in windows.
func Rel(basepath containerfs.ContainerFS, targpath string) (string, error) {
// filepath.Rel can't handle UUID paths in windows
if basepath.OS() == "windows" {
if runtime.GOOS == "windows" {
pfx := basepath.Path() + `\`
if strings.HasPrefix(targpath, pfx) {
p := strings.TrimPrefix(targpath, pfx)

View file

@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"time"
"github.com/docker/docker/pkg/archive"
@ -109,7 +110,7 @@ func (archiver *Archiver) CopyFileWithTar(src, dst string) (retErr error) {
// The original call was system.MkdirAll, which is just
// os.MkdirAll on not-Windows and changed for Windows.
if dstDriver.OS() == "windows" {
if runtime.GOOS == "windows" {
// Now we are WCOW
if err := system.MkdirAll(filepath.Dir(dst), 0700); err != nil {
return err
@ -144,7 +145,7 @@ func (archiver *Archiver) CopyFileWithTar(src, dst string) (retErr error) {
hdr.AccessTime = time.Time{}
hdr.ChangeTime = time.Time{}
hdr.Name = dstDriver.Base(dst)
if dstDriver.OS() == "windows" {
if runtime.GOOS == "windows" {
hdr.Mode = int64(chmodTarEntry(os.FileMode(hdr.Mode)))
} else {
hdr.Mode = int64(os.FileMode(hdr.Mode))

View file

@ -2,7 +2,6 @@ package containerfs // import "github.com/docker/docker/pkg/containerfs"
import (
"path/filepath"
"runtime"
"github.com/containerd/continuity/driver"
"github.com/containerd/continuity/pathdriver"
@ -28,13 +27,6 @@ type ContainerFS interface {
// Driver combines both continuity's Driver and PathDriver interfaces with a Platform
// field to determine the OS.
type Driver interface {
// OS returns the OS where the rootfs is located. Essentially, runtime.GOOS.
OS() string
// Architecture returns the hardware architecture where the
// container is located.
Architecture() string
// Driver & PathDriver provide methods to manipulate files & paths
driver.Driver
pathdriver.PathDriver
@ -76,11 +68,3 @@ func (l *local) ResolveScopedPath(path string, rawPath bool) (string, error) {
}
return symlink.FollowSymlinkInScope(filepath.Join(l.path, cleanedPath), l.path)
}
func (l *local) OS() string {
return runtime.GOOS
}
func (l *local) Architecture() string {
return runtime.GOARCH
}