diff options
author | Baron Lenardson <lenardson.baron@gmail.com> | 2020-12-22 20:29:31 -0600 |
---|---|---|
committer | Baron Lenardson <baron.lenardson@target.com> | 2020-12-24 20:27:41 +0000 |
commit | 76afb50f3ae41a3cc43fca8cc41a2d2f1f1b6dcc (patch) | |
tree | 0adcdac5dc8a124db32a90a386d708fc01922bf7 | |
parent | 8f75ed958562f4deb47799259e22d4f195e0d426 (diff) | |
download | podman-76afb50f3ae41a3cc43fca8cc41a2d2f1f1b6dcc.tar.gz podman-76afb50f3ae41a3cc43fca8cc41a2d2f1f1b6dcc.tar.bz2 podman-76afb50f3ae41a3cc43fca8cc41a2d2f1f1b6dcc.zip |
Consolidate filter logic to pkg subdirectory
Per the conversation on pull/8724 I am consolidating filter logic
and helper functions under the pkg/domain/filters dir.
Signed-off-by: Baron Lenardson <lenardson.baron@gmail.com>
-rw-r--r-- | cmd/podman/system/prune.go | 4 | ||||
-rw-r--r-- | libpod/filters/helpers.go | 20 | ||||
-rw-r--r-- | pkg/api/handlers/compat/containers_prune.go | 4 | ||||
-rw-r--r-- | pkg/api/handlers/utils/pods.go | 4 | ||||
-rw-r--r-- | pkg/domain/filters/containers.go (renamed from libpod/filters/containers.go) | 2 | ||||
-rw-r--r-- | pkg/domain/filters/pods.go (renamed from libpod/filters/pods.go) | 2 | ||||
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 4 | ||||
-rw-r--r-- | pkg/domain/infra/abi/pods.go | 4 | ||||
-rw-r--r-- | pkg/ps/ps.go | 6 |
9 files changed, 15 insertions, 35 deletions
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index a74363684..93b4a1157 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -11,8 +11,8 @@ import ( "github.com/containers/podman/v2/cmd/podman/registry" "github.com/containers/podman/v2/cmd/podman/utils" "github.com/containers/podman/v2/cmd/podman/validate" - lpfilters "github.com/containers/podman/v2/libpod/filters" "github.com/containers/podman/v2/pkg/domain/entities" + dfilters "github.com/containers/podman/v2/pkg/domain/filters" "github.com/spf13/cobra" ) @@ -80,7 +80,7 @@ Are you sure you want to continue? [y/N] `, volumeString) } } - pruneOptions.Filters, err = lpfilters.ParseFilterArgumentsIntoFilters(filters) + pruneOptions.Filters, err = dfilters.ParseFilterArgumentsIntoFilters(filters) if err != nil { return err } diff --git a/libpod/filters/helpers.go b/libpod/filters/helpers.go deleted file mode 100644 index 859db3a9a..000000000 --- a/libpod/filters/helpers.go +++ /dev/null @@ -1,20 +0,0 @@ -package lpfilters - -import ( - "net/url" - "strings" - - "github.com/pkg/errors" -) - -func ParseFilterArgumentsIntoFilters(filters []string) (url.Values, error) { - parsedFilters := make(url.Values) - for _, f := range filters { - t := strings.SplitN(f, "=", 2) - if len(t) < 2 { - return parsedFilters, errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f) - } - parsedFilters.Add(t[0], t[1]) - } - return parsedFilters, nil -} diff --git a/pkg/api/handlers/compat/containers_prune.go b/pkg/api/handlers/compat/containers_prune.go index 2cfeebcce..a1e35dd97 100644 --- a/pkg/api/handlers/compat/containers_prune.go +++ b/pkg/api/handlers/compat/containers_prune.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/containers/podman/v2/libpod" - lpfilters "github.com/containers/podman/v2/libpod/filters" "github.com/containers/podman/v2/pkg/api/handlers/utils" "github.com/containers/podman/v2/pkg/domain/entities" + "github.com/containers/podman/v2/pkg/domain/filters" "github.com/docker/docker/api/types" "github.com/gorilla/schema" "github.com/pkg/errors" @@ -29,7 +29,7 @@ func PruneContainers(w http.ResponseWriter, r *http.Request) { } filterFuncs := make([]libpod.ContainerFilter, 0, len(query.Filters)) for k, v := range query.Filters { - generatedFunc, err := lpfilters.GenerateContainerFilterFuncs(k, v, runtime) + generatedFunc, err := filters.GenerateContainerFilterFuncs(k, v, runtime) if err != nil { utils.InternalServerError(w, err) return diff --git a/pkg/api/handlers/utils/pods.go b/pkg/api/handlers/utils/pods.go index 7506dbfd1..0fe3a308b 100644 --- a/pkg/api/handlers/utils/pods.go +++ b/pkg/api/handlers/utils/pods.go @@ -4,8 +4,8 @@ import ( "net/http" "github.com/containers/podman/v2/libpod" - lpfilters "github.com/containers/podman/v2/libpod/filters" "github.com/containers/podman/v2/pkg/domain/entities" + dfilters "github.com/containers/podman/v2/pkg/domain/filters" "github.com/gorilla/schema" ) @@ -31,7 +31,7 @@ func GetPods(w http.ResponseWriter, r *http.Request) ([]*entities.ListPodsReport filters := make([]libpod.PodFilter, 0, len(query.Filters)) for k, v := range query.Filters { - f, err := lpfilters.GeneratePodFilterFunc(k, v) + f, err := dfilters.GeneratePodFilterFunc(k, v) if err != nil { return nil, err } diff --git a/libpod/filters/containers.go b/pkg/domain/filters/containers.go index 505429de6..6abdd6b57 100644 --- a/libpod/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -1,4 +1,4 @@ -package lpfilters +package filters import ( "strconv" diff --git a/libpod/filters/pods.go b/pkg/domain/filters/pods.go index 17b3f3ca9..7e6b7f2cc 100644 --- a/libpod/filters/pods.go +++ b/pkg/domain/filters/pods.go @@ -1,4 +1,4 @@ -package lpfilters +package filters import ( "strconv" diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index efb4f866f..cfb3421ba 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -16,12 +16,12 @@ import ( "github.com/containers/podman/v2/libpod" "github.com/containers/podman/v2/libpod/define" "github.com/containers/podman/v2/libpod/events" - lpfilters "github.com/containers/podman/v2/libpod/filters" "github.com/containers/podman/v2/libpod/image" "github.com/containers/podman/v2/libpod/logs" "github.com/containers/podman/v2/pkg/cgroups" "github.com/containers/podman/v2/pkg/checkpoint" "github.com/containers/podman/v2/pkg/domain/entities" + dfilters "github.com/containers/podman/v2/pkg/domain/filters" "github.com/containers/podman/v2/pkg/domain/infra/abi/terminal" parallelctr "github.com/containers/podman/v2/pkg/parallel/ctr" "github.com/containers/podman/v2/pkg/ps" @@ -207,7 +207,7 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin func (ic *ContainerEngine) ContainerPrune(ctx context.Context, options entities.ContainerPruneOptions) (*entities.ContainerPruneReport, error) { filterFuncs := make([]libpod.ContainerFilter, 0, len(options.Filters)) for k, v := range options.Filters { - generatedFunc, err := lpfilters.GenerateContainerFilterFuncs(k, v, ic.Libpod) + generatedFunc, err := dfilters.GenerateContainerFilterFuncs(k, v, ic.Libpod) if err != nil { return nil, err } diff --git a/pkg/domain/infra/abi/pods.go b/pkg/domain/infra/abi/pods.go index 11374e513..f108b770c 100644 --- a/pkg/domain/infra/abi/pods.go +++ b/pkg/domain/infra/abi/pods.go @@ -5,8 +5,8 @@ import ( "github.com/containers/podman/v2/libpod" "github.com/containers/podman/v2/libpod/define" - lpfilters "github.com/containers/podman/v2/libpod/filters" "github.com/containers/podman/v2/pkg/domain/entities" + dfilters "github.com/containers/podman/v2/pkg/domain/filters" "github.com/containers/podman/v2/pkg/signal" "github.com/containers/podman/v2/pkg/specgen" "github.com/containers/podman/v2/pkg/specgen/generate" @@ -288,7 +288,7 @@ func (ic *ContainerEngine) PodPs(ctx context.Context, options entities.PodPSOpti filters := make([]libpod.PodFilter, 0, len(options.Filters)) for k, v := range options.Filters { - f, err := lpfilters.GeneratePodFilterFunc(k, v) + f, err := dfilters.GeneratePodFilterFunc(k, v) if err != nil { return nil, err } diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go index 6c26e8708..9e0dcb728 100644 --- a/pkg/ps/ps.go +++ b/pkg/ps/ps.go @@ -11,8 +11,8 @@ import ( "github.com/containers/podman/v2/libpod" "github.com/containers/podman/v2/libpod/define" - lpfilters "github.com/containers/podman/v2/libpod/filters" "github.com/containers/podman/v2/pkg/domain/entities" + "github.com/containers/podman/v2/pkg/domain/filters" psdefine "github.com/containers/podman/v2/pkg/ps/define" "github.com/containers/storage" "github.com/pkg/errors" @@ -27,7 +27,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp all := options.All || options.Last > 0 if len(options.Filters) > 0 { for k, v := range options.Filters { - generatedFunc, err := lpfilters.GenerateContainerFilterFuncs(k, v, runtime) + generatedFunc, err := filters.GenerateContainerFilterFuncs(k, v, runtime) if err != nil { return nil, err } @@ -41,7 +41,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp all = true } if !all { - runningOnly, err := lpfilters.GenerateContainerFilterFuncs("status", []string{define.ContainerStateRunning.String()}, runtime) + runningOnly, err := filters.GenerateContainerFilterFuncs("status", []string{define.ContainerStateRunning.String()}, runtime) if err != nil { return nil, err } |