Skip to content

Commit

Permalink
pkg/containerfs: drop ContainerFS type alias
Browse files Browse the repository at this point in the history
Signed-off-by: Cory Snider <csnider@mirantis.com>
  • Loading branch information
corhere committed Sep 23, 2022
1 parent e332c41 commit 9ce2b30
Show file tree
Hide file tree
Showing 29 changed files with 48 additions and 70 deletions.
5 changes: 2 additions & 3 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
containerpkg "github.com/docker/docker/container"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/containerfs"
)

const (
Expand All @@ -26,7 +25,7 @@ const (
// instructions in the builder.
type Source interface {
// Root returns root path for accessing source
Root() containerfs.ContainerFS
Root() string
// Close allows to signal that the filesystem tree won't be used anymore.
// For Context implementations using a temporary directory, it is recommended to
// delete the temporary directory in Close().
Expand Down Expand Up @@ -110,6 +109,6 @@ type ROLayer interface {
// RWLayer is active layer that can be read/modified
type RWLayer interface {
Release() error
Root() containerfs.ContainerFS
Root() string
Commit() (ROLayer, error)
}
2 changes: 1 addition & 1 deletion builder/dockerfile/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type pathCache interface {
// copyInfo is a data object which stores the metadata about each source file in
// a copyInstruction
type copyInfo struct {
root containerfs.ContainerFS
root string
path string
hash string
noDecompress bool
Expand Down
5 changes: 2 additions & 3 deletions builder/dockerfile/internals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/go-connections/nat"
"github.com/opencontainers/go-digest"
"gotest.tools/v3/assert"
Expand Down Expand Up @@ -183,8 +182,8 @@ func TestDeepCopyRunConfig(t *testing.T) {

type MockRWLayer struct{}

func (l *MockRWLayer) Release() error { return nil }
func (l *MockRWLayer) Root() containerfs.ContainerFS { return "" }
func (l *MockRWLayer) Release() error { return nil }
func (l *MockRWLayer) Root() string { return "" }
func (l *MockRWLayer) Commit() (builder.ROLayer, error) {
return &MockROLayer{
diffID: layer.DiffID(digest.Digest("sha256:1234")),
Expand Down
3 changes: 1 addition & 2 deletions builder/dockerfile/mockbackend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
containerpkg "github.com/docker/docker/container"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/containerfs"
)

// MockBackend implements the builder.Backend interface for unit testing
Expand Down Expand Up @@ -143,6 +142,6 @@ func (l *mockRWLayer) Commit() (builder.ROLayer, error) {
return nil, nil
}

func (l *mockRWLayer) Root() containerfs.ContainerFS {
func (l *mockRWLayer) Root() string {
return ""
}
6 changes: 3 additions & 3 deletions builder/remotecontext/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

type archiveContext struct {
root containerfs.ContainerFS
root string
sums tarsum.FileInfoSums
}

Expand Down Expand Up @@ -82,7 +82,7 @@ func FromArchive(tarStream io.Reader) (builder.Source, error) {
return tsc, nil
}

func (c *archiveContext) Root() containerfs.ContainerFS {
func (c *archiveContext) Root() string {
return c.root
}

Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *archiveContext) Hash(path string) (string, error) {
return path, nil // backwards compat TODO: see if really needed
}

func normalize(path string, root containerfs.ContainerFS) (cleanPath, fullPath string, err error) {
func normalize(path string, root string) (cleanPath, fullPath string, err error) {
cleanPath = filepath.Clean(string(filepath.Separator) + path)[1:]
fullPath, err = containerfs.ResolveScopedPath(root, path)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions builder/remotecontext/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"

"github.com/docker/docker/builder"
"github.com/docker/docker/pkg/containerfs"
)

const (
Expand Down Expand Up @@ -105,14 +104,14 @@ func TestProcessShouldLeaveAllFiles(t *testing.T) {

// TODO: remove after moving to a separate pkg
type stubRemote struct {
root containerfs.ContainerFS
root string
}

func (r *stubRemote) Hash(path string) (string, error) {
return "", errors.New("not implemented")
}

func (r *stubRemote) Root() containerfs.ContainerFS {
func (r *stubRemote) Root() string {
return r.root
}
func (r *stubRemote) Close() error {
Expand Down
9 changes: 4 additions & 5 deletions builder/remotecontext/lazycontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ import (
"strings"

"github.com/docker/docker/builder"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/pools"
"github.com/pkg/errors"
)

// NewLazySource creates a new LazyContext. LazyContext defines a hashed build
// context based on a root directory. Individual files are hashed first time
// they are asked. It is not safe to call methods of LazyContext concurrently.
func NewLazySource(root containerfs.ContainerFS) (builder.Source, error) {
func NewLazySource(root string) (builder.Source, error) {
return &lazySource{
root: root,
sums: make(map[string]string),
}, nil
}

type lazySource struct {
root containerfs.ContainerFS
root string
sums map[string]string
}

func (c *lazySource) Root() containerfs.ContainerFS {
func (c *lazySource) Root() string {
return c.root
}

Expand Down Expand Up @@ -88,7 +87,7 @@ func (c *lazySource) prepareHash(relPath string, fi os.FileInfo) (string, error)

// Rel makes a path relative to base path. Same as `filepath.Rel` but can also
// handle UUID paths in windows.
func Rel(basepath containerfs.ContainerFS, targpath string) (string, error) {
func Rel(basepath string, targpath string) (string, error) {
// filepath.Rel can't handle UUID paths in windows
if runtime.GOOS == "windows" {
pfx := basepath + `\`
Expand Down
5 changes: 2 additions & 3 deletions builder/remotecontext/tarsum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"path/filepath"
"sync"

"github.com/docker/docker/pkg/containerfs"
iradix "github.com/hashicorp/go-immutable-radix"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
Expand All @@ -19,7 +18,7 @@ type hashed interface {
// CachableSource is a source that contains cache records for its contents
type CachableSource struct {
mu sync.Mutex
root containerfs.ContainerFS
root string
tree *iradix.Tree
txn *iradix.Txn
}
Expand Down Expand Up @@ -145,7 +144,7 @@ func (cs *CachableSource) Hash(path string) (string, error) {
}

// Root returns a root directory for the source
func (cs *CachableSource) Root() containerfs.ContainerFS {
func (cs *CachableSource) Root() string {
return cs.root
}

Expand Down
8 changes: 4 additions & 4 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ type ExitStatus struct {
type Container struct {
StreamConfig *stream.Config
// embed for Container to support states directly.
*State `json:"State"` // Needed for Engine API version <= 1.11
Root string `json:"-"` // Path to the "home" of the container, including metadata.
BaseFS containerfs.ContainerFS `json:"-"` // interface containing graphdriver mount
RWLayer layer.RWLayer `json:"-"`
*State `json:"State"` // Needed for Engine API version <= 1.11
Root string `json:"-"` // Path to the "home" of the container, including metadata.
BaseFS string `json:"-"` // Path to the graphdriver mountpoint
RWLayer layer.RWLayer `json:"-"`
ID string
Created time.Time
Managed bool
Expand Down
5 changes: 2 additions & 3 deletions daemon/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/docker/docker/libnetwork/options"
lntypes "github.com/docker/docker/libnetwork/types"
"github.com/docker/docker/opts"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/parsers/kernel"
Expand Down Expand Up @@ -1072,8 +1071,8 @@ func removeDefaultBridgeInterface() {
}
}

func setupInitLayer(idMapping idtools.IdentityMapping) func(containerfs.ContainerFS) error {
return func(initPath containerfs.ContainerFS) error {
func setupInitLayer(idMapping idtools.IdentityMapping) func(string) error {
return func(initPath string) error {
return initlayer.Setup(initPath, idMapping.RootPair())
}
}
Expand Down
3 changes: 1 addition & 2 deletions daemon/daemon_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
winlibnetwork "github.com/docker/docker/libnetwork/drivers/windows"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/options"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/parsers/operatingsystem"
Expand Down Expand Up @@ -64,7 +63,7 @@ func (daemon *Daemon) parseSecurityOpt(container *container.Container, hostConfi
return nil
}

func setupInitLayer(idMapping idtools.IdentityMapping) func(containerfs.ContainerFS) error {
func setupInitLayer(idMapping idtools.IdentityMapping) func(string) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/aufs/aufs.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func atomicRemove(source string) error {

// Get returns the rootfs path for the id.
// This will mount the dir at its given path
func (a *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
func (a *Driver) Get(id, mountLabel string) (string, error) {
a.locker.Lock(id)
defer a.locker.Unlock(id)
parents, err := a.getParentLayerPaths(id)
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/btrfs/btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func (d *Driver) Remove(id string) error {
}

// Get the requested filesystem id.
func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
func (d *Driver) Get(id, mountLabel string) (string, error) {
dir := d.subvolumesDirID(id)
st, err := os.Stat(dir)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions daemon/graphdriver/devmapper/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strconv"

"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/devicemapper"
"github.com/docker/docker/pkg/idtools"
units "github.com/docker/go-units"
Expand Down Expand Up @@ -175,7 +174,7 @@ func (d *Driver) Remove(id string) error {
}

// Get mounts a device with given id into the root filesystem
func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
func (d *Driver) Get(id, mountLabel string) (string, error) {
d.locker.Lock(id)
defer d.locker.Unlock(id)
mp := path.Join(d.home, "mnt", id)
Expand Down
3 changes: 1 addition & 2 deletions daemon/graphdriver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"

"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/plugingetter"
"github.com/pkg/errors"
Expand Down Expand Up @@ -60,7 +59,7 @@ type ProtoDriver interface {
// Get returns the mountpoint for the layered filesystem referred
// to by this id. You can optionally specify a mountLabel or "".
// Returns the absolute path to the mounted layered filesystem.
Get(id, mountLabel string) (fs containerfs.ContainerFS, err error)
Get(id, mountLabel string) (fs string, err error)
// Put releases the system resources for the specified id,
// e.g, unmounting layered filesystem.
Put(id string) error
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (d *Driver) Remove(id string) error {
}

// Get creates and mounts the required file system for the given id and returns the mount path.
func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr error) {
func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
d.locker.Lock(id)
defer d.locker.Unlock(id)
dir := d.dir(id)
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (d *Driver) Remove(id string) error {
}

// Get creates and mounts the required file system for the given id and returns the mount path.
func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, err error) {
func (d *Driver) Get(id, mountLabel string) (_ string, err error) {
d.locker.Lock(id)
defer d.locker.Unlock(id)
dir := d.dir(id)
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/overlay2/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func (d *Driver) Remove(id string) error {
}

// Get creates and mounts the required file system for the given id and returns the mount path.
func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr error) {
func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
d.locker.Lock(id)
defer d.locker.Unlock(id)
dir := d.dir(id)
Expand Down
3 changes: 1 addition & 2 deletions daemon/graphdriver/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"

"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/docker/pkg/plugins"
Expand Down Expand Up @@ -128,7 +127,7 @@ func (d *graphDriverProxy) Remove(id string) error {
return nil
}

func (d *graphDriverProxy) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
func (d *graphDriverProxy) Get(id, mountLabel string) (string, error) {
args := &graphDriverRequest{
ID: id,
MountLabel: mountLabel,
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/vfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (d *Driver) Remove(id string) error {
}

// Get returns the directory for the given id.
func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
func (d *Driver) Get(id, mountLabel string) (string, error) {
dir := d.dir(id)
if st, err := os.Stat(dir); err != nil {
return "", err
Expand Down
3 changes: 1 addition & 2 deletions daemon/graphdriver/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/Microsoft/hcsshim/osversion"
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/longpath"
Expand Down Expand Up @@ -393,7 +392,7 @@ func (d *Driver) GetLayerPath(id string) (string, error) {
}

// Get returns the rootfs path for the id. This will mount the dir at its given path.
func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
func (d *Driver) Get(id, mountLabel string) (string, error) {
logrus.Debugf("WindowsGraphDriver Get() id %s mountLabel %s", id, mountLabel)
var dir string

Expand Down
3 changes: 1 addition & 2 deletions daemon/graphdriver/zfs/zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"time"

"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/parsers"
zfs "github.com/mistifyio/go-zfs"
Expand Down Expand Up @@ -363,7 +362,7 @@ func (d *Driver) Remove(id string) error {
}

// Get returns the mountpoint for the given id after creating the target directories if necessary.
func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr error) {
func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
d.locker.Lock(id)
defer d.locker.Unlock(id)
mountpoint := d.mountPath(id)
Expand Down
5 changes: 2 additions & 3 deletions daemon/images/image_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/docker/docker/errdefs"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/stringid"
Expand Down Expand Up @@ -83,10 +82,10 @@ type rwLayer struct {
released bool
layerStore layer.Store
rwLayer layer.RWLayer
fs containerfs.ContainerFS
fs string
}

func (l *rwLayer) Root() containerfs.ContainerFS {
func (l *rwLayer) Root() string {
return l.fs
}

Expand Down
Loading

0 comments on commit 9ce2b30

Please sign in to comment.