1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #33640 from dsheets/pluginv2-static-start-but-disabled-error

plugin/store.Get: return a specific error if plugin is disabled
This commit is contained in:
Vincent Demeester 2017-06-14 15:35:26 +02:00 committed by GitHub
commit 397a57d3a5

View file

@ -29,13 +29,20 @@ type ErrNotFound string
func (name ErrNotFound) Error() string { return fmt.Sprintf("plugin %q not found", string(name)) } func (name ErrNotFound) Error() string { return fmt.Sprintf("plugin %q not found", string(name)) }
// ErrAmbiguous indicates that a plugin was not found locally. // ErrAmbiguous indicates that more than one plugin was found
type ErrAmbiguous string type ErrAmbiguous string
func (name ErrAmbiguous) Error() string { func (name ErrAmbiguous) Error() string {
return fmt.Sprintf("multiple plugins found for %q", string(name)) 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. // GetV2Plugin retrieves a plugin by name, id or partial ID.
func (ps *Store) GetV2Plugin(refOrID string) (*v2.Plugin, error) { func (ps *Store) GetV2Plugin(refOrID string) (*v2.Plugin, error) {
ps.RLock() 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 // Plugin was found but it is disabled, so we should not fall back to legacy plugins
// but we should error out right away // but we should error out right away
return nil, ErrNotFound(name) return nil, ErrDisabled(name)
} }
if _, ok := errors.Cause(err).(ErrNotFound); !ok { if _, ok := errors.Cause(err).(ErrNotFound); !ok {
return nil, err return nil, err