When `-s` is not specified, there is no need to ask if there is a plugin
with the specified name.
This speeds up unit tests dramatically since they don't need to wait the
timeout period for each call to `graphdriver.New`.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -118,6 +118,15 @@ func GetDriver(name, home string, options []string) (Driver, error) {
|
| 118 | 118 |
return nil, ErrNotSupported |
| 119 | 119 |
} |
| 120 | 120 |
|
| 121 |
+// getBuiltinDriver initalizes and returns the registered driver, but does not try to load from plugins |
|
| 122 |
+func getBuiltinDriver(name, home string, options []string) (Driver, error) {
|
|
| 123 |
+ if initFunc, exists := drivers[name]; exists {
|
|
| 124 |
+ return initFunc(filepath.Join(home, name), options) |
|
| 125 |
+ } |
|
| 126 |
+ logrus.Errorf("Failed to built-in GetDriver graph %s %s", name, home)
|
|
| 127 |
+ return nil, ErrNotSupported |
|
| 128 |
+} |
|
| 129 |
+ |
|
| 121 | 130 |
// New creates the driver and initializes it at the specified root. |
| 122 | 131 |
func New(root string, options []string) (driver Driver, err error) {
|
| 123 | 132 |
for _, name := range []string{os.Getenv("DOCKER_DRIVER"), DefaultDriver} {
|
| ... | ... |
@@ -138,7 +147,7 @@ func New(root string, options []string) (driver Driver, err error) {
|
| 138 | 138 |
// of the state found from prior drivers, check in order of our priority |
| 139 | 139 |
// which we would prefer |
| 140 | 140 |
if prior == name {
|
| 141 |
- driver, err = GetDriver(name, root, options) |
|
| 141 |
+ driver, err = getBuiltinDriver(name, root, options) |
|
| 142 | 142 |
if err != nil {
|
| 143 | 143 |
// unlike below, we will return error here, because there is prior |
| 144 | 144 |
// state, and now it is no longer supported/prereq/compatible, so |
| ... | ... |
@@ -158,7 +167,7 @@ func New(root string, options []string) (driver Driver, err error) {
|
| 158 | 158 |
|
| 159 | 159 |
// Check for priority drivers first |
| 160 | 160 |
for _, name := range priority {
|
| 161 |
- driver, err = GetDriver(name, root, options) |
|
| 161 |
+ driver, err = getBuiltinDriver(name, root, options) |
|
| 162 | 162 |
if err != nil {
|
| 163 | 163 |
if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS {
|
| 164 | 164 |
continue |