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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-06-27 17:29:26 +02:00
parent b7896056c1
commit 84cabde357
4 changed files with 9 additions and 4 deletions

View File

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

View File

@@ -30,11 +30,16 @@ type Driver struct {
}
func newDriver(t testing.TB, name string, options []string) *Driver {
if name == "" {
// Prevent graphdriver.New() from auto-detecting / picking a storage driver.
t.Fatal("newDriver requires a name for the storage driver to use")
}
root, err := os.MkdirTemp("", "docker-graphtest-")
assert.NilError(t, err)
assert.NilError(t, os.MkdirAll(root, 0o755))
d, err := graphdriver.GetDriver(name, graphdriver.Options{DriverOptions: options, Root: root})
d, err := graphdriver.New(name, graphdriver.Options{DriverOptions: options, Root: root})
if err != nil {
t.Logf("graphdriver: %v\n", err)
if graphdriver.IsDriverNotSupported(err) {

View File

@@ -92,7 +92,7 @@ func TestXattrUnsupportedByBackingFS(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
subdir := filepath.Join(rootdir, tt.name)
assert.NilError(t, os.Mkdir(subdir, 0o755))
d, err := graphdriver.GetDriver("vfs", graphdriver.Options{
d, err := graphdriver.New("vfs", graphdriver.Options{
DriverOptions: tt.opts,
Root: subdir,
})

View File

@@ -26,7 +26,7 @@ func init() {
}
func newVFSGraphDriver(td string) (graphdriver.Driver, error) {
return graphdriver.GetDriver("vfs", graphdriver.Options{
return graphdriver.New("vfs", graphdriver.Options{
Root: td,
IDMap: idtools.IdentityMapping{
UIDMaps: []idtools.IDMap{{