Files
moby/client/plugin_list.go
Sebastiaan van Stijn 15a048c396 api, client: don't use a pointer-slice for plugins
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>
2025-11-07 21:02:26 +01:00

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
}