Skip to content

Commit 84cabde

Browse files
committed
daemon/graphdriver: deprecate GetDriver(), and remove its use
The exported function was only used in tests, and identical in use when using New with a name provided. Deprecate it, and remove the uses of it in our (integration-)tests. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent b789605 commit 84cabde

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

daemon/graphdriver/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func Register(name string, initFunc InitFunc) error {
158158

159159
// GetDriver initializes and returns the registered driver.
160160
//
161-
// It is exported for use in (integration-)tests, but should be considered internal.
161+
// Deprecated: this function was exported for (integration-)tests, but no longer used, and will be removed in the next release.
162162
func GetDriver(name string, config Options) (Driver, error) {
163163
return getDriver(name, config)
164164
}

daemon/graphdriver/graphtest/graphtest_unix.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ type Driver struct {
3030
}
3131

3232
func newDriver(t testing.TB, name string, options []string) *Driver {
33+
if name == "" {
34+
// Prevent graphdriver.New() from auto-detecting / picking a storage driver.
35+
t.Fatal("newDriver requires a name for the storage driver to use")
36+
}
37+
3338
root, err := os.MkdirTemp("", "docker-graphtest-")
3439
assert.NilError(t, err)
3540

3641
assert.NilError(t, os.MkdirAll(root, 0o755))
37-
d, err := graphdriver.GetDriver(name, graphdriver.Options{DriverOptions: options, Root: root})
42+
d, err := graphdriver.New(name, graphdriver.Options{DriverOptions: options, Root: root})
3843
if err != nil {
3944
t.Logf("graphdriver: %v\n", err)
4045
if graphdriver.IsDriverNotSupported(err) {

daemon/graphdriver/vfs/vfs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestXattrUnsupportedByBackingFS(t *testing.T) {
9292
t.Run(tt.name, func(t *testing.T) {
9393
subdir := filepath.Join(rootdir, tt.name)
9494
assert.NilError(t, os.Mkdir(subdir, 0o755))
95-
d, err := graphdriver.GetDriver("vfs", graphdriver.Options{
95+
d, err := graphdriver.New("vfs", graphdriver.Options{
9696
DriverOptions: tt.opts,
9797
Root: subdir,
9898
})

layer/layer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func init() {
2626
}
2727

2828
func newVFSGraphDriver(td string) (graphdriver.Driver, error) {
29-
return graphdriver.GetDriver("vfs", graphdriver.Options{
29+
return graphdriver.New("vfs", graphdriver.Options{
3030
Root: td,
3131
IDMap: idtools.IdentityMapping{
3232
UIDMaps: []idtools.IDMap{{

0 commit comments

Comments
 (0)