mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: Client.PluginList: add options-struct
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -148,7 +148,7 @@ type NodeAPIClient interface {
|
||||
|
||||
// PluginAPIClient defines API client methods for the plugins
|
||||
type PluginAPIClient interface {
|
||||
PluginList(ctx context.Context, filter Filters) (plugin.ListResponse, error)
|
||||
PluginList(ctx context.Context, opts PluginListOptions) (plugin.ListResponse, error)
|
||||
PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) error
|
||||
PluginEnable(ctx context.Context, name string, options PluginEnableOptions) error
|
||||
PluginDisable(ctx context.Context, name string, options PluginDisableOptions) error
|
||||
|
||||
@@ -8,12 +8,17 @@ import (
|
||||
"github.com/moby/moby/api/types/plugin"
|
||||
)
|
||||
|
||||
// PluginListOptions holds parameters to list plugins.
|
||||
type PluginListOptions struct {
|
||||
Filters Filters
|
||||
}
|
||||
|
||||
// PluginList returns the installed plugins
|
||||
func (cli *Client) PluginList(ctx context.Context, filter Filters) (plugin.ListResponse, error) {
|
||||
func (cli *Client) PluginList(ctx context.Context, opts PluginListOptions) (plugin.ListResponse, error) {
|
||||
var plugins plugin.ListResponse
|
||||
query := url.Values{}
|
||||
|
||||
filter.updateURLValues(query)
|
||||
opts.Filters.updateURLValues(query)
|
||||
resp, err := cli.get(ctx, "/plugins", query, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestPluginListError(t *testing.T) {
|
||||
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error")))
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = client.PluginList(context.Background(), nil)
|
||||
_, err = client.PluginList(context.Background(), PluginListOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
@@ -85,7 +85,9 @@ func TestPluginList(t *testing.T) {
|
||||
}))
|
||||
assert.NilError(t, err)
|
||||
|
||||
plugins, err := client.PluginList(context.Background(), listCase.filters)
|
||||
plugins, err := client.PluginList(context.Background(), PluginListOptions{
|
||||
Filters: listCase.filters,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(plugins, 2))
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ func deleteAllNetworks(ctx context.Context, t testing.TB, c client.NetworkAPICli
|
||||
|
||||
func deleteAllPlugins(ctx context.Context, t testing.TB, c client.PluginAPIClient, protectedPlugins map[string]struct{}) {
|
||||
t.Helper()
|
||||
plugins, err := c.PluginList(ctx, nil)
|
||||
plugins, err := c.PluginList(ctx, client.PluginListOptions{})
|
||||
// Docker EE does not allow cluster-wide plugin management.
|
||||
if cerrdefs.IsNotImplemented(err) {
|
||||
return
|
||||
|
||||
@@ -193,8 +193,8 @@ func ProtectPlugins(ctx context.Context, t testing.TB, testEnv *Execution) {
|
||||
|
||||
func getExistingPlugins(ctx context.Context, t testing.TB, testEnv *Execution) []string {
|
||||
t.Helper()
|
||||
client := testEnv.APIClient()
|
||||
pluginList, err := client.PluginList(ctx, nil)
|
||||
apiClient := testEnv.APIClient()
|
||||
pluginList, err := apiClient.PluginList(ctx, client.PluginListOptions{})
|
||||
// Docker EE does not allow cluster-wide plugin management.
|
||||
if cerrdefs.IsNotImplemented(err) {
|
||||
return []string{}
|
||||
|
||||
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
@@ -148,7 +148,7 @@ type NodeAPIClient interface {
|
||||
|
||||
// PluginAPIClient defines API client methods for the plugins
|
||||
type PluginAPIClient interface {
|
||||
PluginList(ctx context.Context, filter Filters) (plugin.ListResponse, error)
|
||||
PluginList(ctx context.Context, opts PluginListOptions) (plugin.ListResponse, error)
|
||||
PluginRemove(ctx context.Context, name string, options PluginRemoveOptions) error
|
||||
PluginEnable(ctx context.Context, name string, options PluginEnableOptions) error
|
||||
PluginDisable(ctx context.Context, name string, options PluginDisableOptions) error
|
||||
|
||||
9
vendor/github.com/moby/moby/client/plugin_list.go
generated
vendored
9
vendor/github.com/moby/moby/client/plugin_list.go
generated
vendored
@@ -8,12 +8,17 @@ import (
|
||||
"github.com/moby/moby/api/types/plugin"
|
||||
)
|
||||
|
||||
// PluginListOptions holds parameters to list plugins.
|
||||
type PluginListOptions struct {
|
||||
Filters Filters
|
||||
}
|
||||
|
||||
// PluginList returns the installed plugins
|
||||
func (cli *Client) PluginList(ctx context.Context, filter Filters) (plugin.ListResponse, error) {
|
||||
func (cli *Client) PluginList(ctx context.Context, opts PluginListOptions) (plugin.ListResponse, error) {
|
||||
var plugins plugin.ListResponse
|
||||
query := url.Values{}
|
||||
|
||||
filter.updateURLValues(query)
|
||||
opts.Filters.updateURLValues(query)
|
||||
resp, err := cli.get(ctx, "/plugins", query, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user