From e33d598059d8af8c57995a2c52f1f9f5691c09e8 Mon Sep 17 00:00:00 2001 From: David Sheets Date: Mon, 12 Jun 2017 15:36:46 +0100 Subject: [PATCH] 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 --- plugin/store.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/store.go b/plugin/store.go index 244522e10a..285489f4bf 100644 --- a/plugin/store.go +++ b/plugin/store.go @@ -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