plugin/store.Get: return a specific error if plugin is disabled

Previously, a 'plugin not found' error would be returned if a plugin to be
retrieved was found but disabled. This was misleading and incorrect. Now,
a new error plugin.ErrDisabled is returned in this case. This makes the
error message when trying to statically start plugins (from daemon.json or
dockerd command line) accurate.

Signed-off-by: David Sheets <dsheets@docker.com>
This commit is contained in:
David Sheets 2017-06-12 15:36:46 +01:00
parent 3f6b6c2981
commit e33d598059
1 changed files with 8 additions and 1 deletions

View File

@ -36,6 +36,13 @@ func (name ErrAmbiguous) Error() string {
return fmt.Sprintf("multiple plugins found for %q", string(name))
}
// ErrDisabled indicates that a plugin was found but it is disabled
type ErrDisabled string
func (name ErrDisabled) Error() string {
return fmt.Sprintf("plugin %s found but disabled", string(name))
}
// GetV2Plugin retrieves a plugin by name, id or partial ID.
func (ps *Store) GetV2Plugin(refOrID string) (*v2.Plugin, error) {
ps.RLock()
@ -138,7 +145,7 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug
}
// Plugin was found but it is disabled, so we should not fall back to legacy plugins
// but we should error out right away
return nil, ErrNotFound(name)
return nil, ErrDisabled(name)
}
if _, ok := errors.Cause(err).(ErrNotFound); !ok {
return nil, err