client: add Filters type

Add a new type to use for building filter predicates for API requests,
replacing "./api/types/filters".Args in the client. Remove the now
unused api/types/filters package.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider
2025-10-06 15:18:41 -04:00
parent 778e5bfad3
commit 7ea066c8d1
106 changed files with 380 additions and 853 deletions

View File

@@ -10,7 +10,6 @@ import (
"testing"
cerrdefs "github.com/containerd/errdefs"
"github.com/moby/moby/api/types/filters"
"github.com/moby/moby/api/types/plugin"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@@ -20,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(), filters.NewArgs())
_, err = client.PluginList(context.Background(), nil)
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
}
@@ -28,11 +27,10 @@ func TestPluginList(t *testing.T) {
const expectedURL = "/plugins"
listCases := []struct {
filters filters.Args
filters Filters
expectedQueryParams map[string]string
}{
{
filters: filters.NewArgs(),
expectedQueryParams: map[string]string{
"all": "",
"filter": "",
@@ -40,7 +38,7 @@ func TestPluginList(t *testing.T) {
},
},
{
filters: filters.NewArgs(filters.Arg("enabled", "true")),
filters: make(Filters).Add("enabled", "true"),
expectedQueryParams: map[string]string{
"all": "",
"filter": "",
@@ -48,10 +46,7 @@ func TestPluginList(t *testing.T) {
},
},
{
filters: filters.NewArgs(
filters.Arg("capability", "volumedriver"),
filters.Arg("capability", "authz"),
),
filters: make(Filters).Add("capability", "volumedriver", "authz"),
expectedQueryParams: map[string]string{
"all": "",
"filter": "",