mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Handle plugin list not implemented
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
This commit is contained in:
parent
7cbbbb9509
commit
e7e11bdd44
2 changed files with 23 additions and 1 deletions
|
@ -64,6 +64,8 @@ func wrapResponseError(err error, resp serverResponse, object, id string) error
|
||||||
return nil
|
return nil
|
||||||
case resp.statusCode == http.StatusNotFound:
|
case resp.statusCode == http.StatusNotFound:
|
||||||
return objectNotFoundError{object: object, id: id}
|
return objectNotFoundError{object: object, id: id}
|
||||||
|
case resp.statusCode == http.StatusNotImplemented:
|
||||||
|
return notImplementedError{message: err.Error()}
|
||||||
default:
|
default:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -157,6 +159,26 @@ func IsErrPluginPermissionDenied(err error) bool {
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type notImplementedError struct {
|
||||||
|
message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e notImplementedError) Error() string {
|
||||||
|
return e.message
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e notImplementedError) NotImplemented() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNotImplementedError returns true if the error is a NotImplemented error.
|
||||||
|
// This is returned by the API when a requested feature has not been
|
||||||
|
// implemented.
|
||||||
|
func IsNotImplementedError(err error) bool {
|
||||||
|
te, ok := err.(notImplementedError)
|
||||||
|
return ok && te.NotImplemented()
|
||||||
|
}
|
||||||
|
|
||||||
// NewVersionError returns an error if the APIVersion required
|
// NewVersionError returns an error if the APIVersion required
|
||||||
// if less than the current supported version
|
// if less than the current supported version
|
||||||
func (cli *Client) NewVersionError(APIrequired, feature string) error {
|
func (cli *Client) NewVersionError(APIrequired, feature string) error {
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (cli *Client) PluginList(ctx context.Context, filter filters.Args) (types.P
|
||||||
}
|
}
|
||||||
resp, err := cli.get(ctx, "/plugins", query, nil)
|
resp, err := cli.get(ctx, "/plugins", query, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return plugins, err
|
return plugins, wrapResponseError(err, resp, "plugin", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.NewDecoder(resp.body).Decode(&plugins)
|
err = json.NewDecoder(resp.body).Decode(&plugins)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue