summaryrefslogtreecommitdiff
path: root/layer
diff options
context:
space:
mode:
authorCory Snider <csnider@mirantis.com>2022-09-22 20:59:58 -0400
committerCory Snider <csnider@mirantis.com>2022-09-23 16:25:22 -0400
commitbe4f4644a8ebb940f0d68dc66f59327a74775ad6 (patch)
tree8099e937db35e858c18f383d52bc2f37fe57e4ca /layer
parent7014c0d65d5038eab0c902579394695245f2563d (diff)
downloaddocker-be4f4644a8ebb940f0d68dc66f59327a74775ad6.tar.gz
pkg/containerfs: drop Driver abstraction
The Driver abstraction was needed for Linux Containers on Windows, support for which has since been removed. There is no direct equivalent to Lchmod() in the standard library so continue to use the containerd/continuity version. Signed-off-by: Cory Snider <csnider@mirantis.com>
Diffstat (limited to 'layer')
-rw-r--r--layer/layer_test.go14
-rw-r--r--layer/mount_test.go19
2 files changed, 17 insertions, 16 deletions
diff --git a/layer/layer_test.go b/layer/layer_test.go
index 6ccc52d925..dcb759c0b9 100644
--- a/layer/layer_test.go
+++ b/layer/layer_test.go
@@ -140,16 +140,16 @@ func newTestFile(name string, content []byte, perm os.FileMode) FileApplier {
func (tf *testFile) ApplyFile(root containerfs.ContainerFS) error {
fullPath := filepath.Join(root.Path(), tf.name)
- if err := root.MkdirAll(filepath.Dir(fullPath), 0755); err != nil {
+ if err := os.MkdirAll(filepath.Dir(fullPath), 0755); err != nil {
return err
}
// Check if already exists
- if stat, err := root.Stat(fullPath); err == nil && stat.Mode().Perm() != tf.permission {
- if err := root.Lchmod(fullPath, tf.permission); err != nil {
+ if stat, err := os.Stat(fullPath); err == nil && stat.Mode().Perm() != tf.permission {
+ if err := driver.LocalDriver.Lchmod(fullPath, tf.permission); err != nil {
return err
}
}
- return driver.WriteFile(root, fullPath, tf.content, tf.permission)
+ return os.WriteFile(fullPath, tf.content, tf.permission)
}
func initWithFiles(files ...FileApplier) layerInit {
@@ -267,7 +267,7 @@ func TestMountAndRegister(t *testing.T) {
t.Fatal(err)
}
- b, err := driver.ReadFile(path2, filepath.Join(path2.Path(), "testfile.txt"))
+ b, err := os.ReadFile(filepath.Join(path2.Path(), "testfile.txt"))
if err != nil {
t.Fatal(err)
}
@@ -375,7 +375,7 @@ func TestStoreRestore(t *testing.T) {
t.Fatal(err)
}
- if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "testfile.txt"), []byte("nothing here"), 0644); err != nil {
+ if err := os.WriteFile(filepath.Join(pathFS.Path(), "testfile.txt"), []byte("nothing here"), 0644); err != nil {
t.Fatal(err)
}
@@ -422,7 +422,7 @@ func TestStoreRestore(t *testing.T) {
t.Fatal(err)
}
- b, err := driver.ReadFile(pathFS, filepath.Join(pathFS.Path(), "testfile.txt"))
+ b, err := os.ReadFile(filepath.Join(pathFS.Path(), "testfile.txt"))
if err != nil {
t.Fatal(err)
}
diff --git a/layer/mount_test.go b/layer/mount_test.go
index 1778d16727..8b17afbe84 100644
--- a/layer/mount_test.go
+++ b/layer/mount_test.go
@@ -2,6 +2,7 @@ package layer // import "github.com/docker/docker/layer"
import (
"io"
+ "os"
"path/filepath"
"runtime"
"sort"
@@ -46,12 +47,12 @@ func TestMountInit(t *testing.T) {
t.Fatal(err)
}
- fi, err := pathFS.Stat(filepath.Join(pathFS.Path(), "testfile.txt"))
+ fi, err := os.Stat(filepath.Join(pathFS.Path(), "testfile.txt"))
if err != nil {
t.Fatal(err)
}
- f, err := pathFS.Open(filepath.Join(pathFS.Path(), "testfile.txt"))
+ f, err := os.Open(filepath.Join(pathFS.Path(), "testfile.txt"))
if err != nil {
t.Fatal(err)
}
@@ -106,7 +107,7 @@ func TestMountSize(t *testing.T) {
t.Fatal(err)
}
- if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "file2"), content2, 0755); err != nil {
+ if err := os.WriteFile(filepath.Join(pathFS.Path(), "file2"), content2, 0755); err != nil {
t.Fatal(err)
}
@@ -158,23 +159,23 @@ func TestMountChanges(t *testing.T) {
t.Fatal(err)
}
- if err := pathFS.Lchmod(filepath.Join(pathFS.Path(), "testfile1.txt"), 0755); err != nil {
+ if err := driver.LocalDriver.Lchmod(filepath.Join(pathFS.Path(), "testfile1.txt"), 0755); err != nil {
t.Fatal(err)
}
- if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "testfile1.txt"), []byte("mount data!"), 0755); err != nil {
+ if err := os.WriteFile(filepath.Join(pathFS.Path(), "testfile1.txt"), []byte("mount data!"), 0755); err != nil {
t.Fatal(err)
}
- if err := pathFS.Remove(filepath.Join(pathFS.Path(), "testfile2.txt")); err != nil {
+ if err := os.Remove(filepath.Join(pathFS.Path(), "testfile2.txt")); err != nil {
t.Fatal(err)
}
- if err := pathFS.Lchmod(filepath.Join(pathFS.Path(), "testfile3.txt"), 0755); err != nil {
+ if err := driver.LocalDriver.Lchmod(filepath.Join(pathFS.Path(), "testfile3.txt"), 0755); err != nil {
t.Fatal(err)
}
- if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "testfile4.txt"), []byte("mount data!"), 0644); err != nil {
+ if err := os.WriteFile(filepath.Join(pathFS.Path(), "testfile4.txt"), []byte("mount data!"), 0644); err != nil {
t.Fatal(err)
}
@@ -249,7 +250,7 @@ func TestMountApply(t *testing.T) {
t.Fatal(err)
}
- f, err := pathFS.Open(filepath.Join(pathFS.Path(), "newfile.txt"))
+ f, err := os.Open(filepath.Join(pathFS.Path(), "newfile.txt"))
if err != nil {
t.Fatal(err)
}