mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
The backend and router don't use a pointer-slice (the server actually doesn't use the `plugin.ListResponse` type and a straight slice);778e5bfad3/daemon/server/router/plugin/backend.go (L20)6baf274fa3/daemon/server/router/plugin/plugin_routes.go (L276-L280)Align the type in the API to match, and update the type defined in the client accordingly. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
36 lines
826 B
Go
36 lines
826 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/moby/moby/api/types/plugin"
|
|
)
|
|
|
|
// PluginListOptions holds parameters to list plugins.
|
|
type PluginListOptions struct {
|
|
Filters Filters
|
|
}
|
|
|
|
// PluginListResult represents the result of a plugin list operation.
|
|
type PluginListResult struct {
|
|
Items []plugin.Plugin
|
|
}
|
|
|
|
// PluginList returns the installed plugins
|
|
func (cli *Client) PluginList(ctx context.Context, options PluginListOptions) (PluginListResult, error) {
|
|
query := url.Values{}
|
|
|
|
options.Filters.updateURLValues(query)
|
|
resp, err := cli.get(ctx, "/plugins", query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return PluginListResult{}, err
|
|
}
|
|
|
|
var plugins plugin.ListResponse
|
|
err = json.NewDecoder(resp.Body).Decode(&plugins)
|
|
return PluginListResult{Items: plugins}, err
|
|
}
|