Last active
August 29, 2015 14:22
-
-
Save tanksuzuki/f3a2680d988228c238b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func New(root string, options []string) (driver Driver, err error) { | |
for _, name := range []string{os.Getenv("DOCKER_DRIVER"), DefaultDriver} { | |
if name != "" { | |
return GetDriver(name, root, options) | |
} | |
} | |
// Check for priority drivers first | |
for _, name := range priority { | |
driver, err = GetDriver(name, root, options) | |
if err != nil { | |
if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS { | |
continue | |
} | |
return nil, err | |
} | |
checkPriorDriver(name, root) | |
return driver, nil | |
} | |
// Check all registered drivers if no priority driver is found | |
for name, initFunc := range drivers { | |
if driver, err = initFunc(root, options); err != nil { | |
if err == ErrNotSupported || err == ErrPrerequisites || err == ErrIncompatibleFS { | |
continue | |
} | |
return nil, err | |
} | |
checkPriorDriver(name, root) | |
return driver, nil | |
} | |
return nil, fmt.Errorf("No supported storage backend found") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment