diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/common/completion.go | 9 | ||||
-rw-r--r-- | cmd/podman/common/specgen.go | 6 | ||||
-rw-r--r-- | cmd/podman/networks/list.go | 2 | ||||
-rw-r--r-- | cmd/podman/parse/filters.go | 20 | ||||
-rw-r--r-- | cmd/podman/system/prune.go | 4 | ||||
-rw-r--r-- | cmd/podman/volumes/prune.go | 6 |
6 files changed, 33 insertions, 14 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go index 7629a8145..bc106263c 100644 --- a/cmd/podman/common/completion.go +++ b/cmd/podman/common/completion.go @@ -8,12 +8,11 @@ import ( "github.com/containers/common/pkg/config" "github.com/containers/podman/v3/cmd/podman/registry" - "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/registries" "github.com/containers/podman/v3/pkg/rootless" - systemdGen "github.com/containers/podman/v3/pkg/systemd/generate" + systemdDefine "github.com/containers/podman/v3/pkg/systemd/define" "github.com/containers/podman/v3/pkg/util" "github.com/spf13/cobra" ) @@ -732,8 +731,8 @@ func AutocompletePullOption(cmd *cobra.Command, args []string, toComplete string // AutocompleteRestartOption - Autocomplete restart options for create and run command. // -> "always", "no", "on-failure", "unless-stopped" func AutocompleteRestartOption(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - restartOptions := []string{libpod.RestartPolicyAlways, libpod.RestartPolicyNo, - libpod.RestartPolicyOnFailure, libpod.RestartPolicyUnlessStopped} + restartOptions := []string{define.RestartPolicyAlways, define.RestartPolicyNo, + define.RestartPolicyOnFailure, define.RestartPolicyUnlessStopped} return restartOptions, cobra.ShellCompDirectiveNoFileComp } @@ -908,7 +907,7 @@ func AutocompleteEventFilter(cmd *cobra.Command, args []string, toComplete strin // AutocompleteSystemdRestartOptions - Autocomplete systemd restart options. // -> "no", "on-success", "on-failure", "on-abnormal", "on-watchdog", "on-abort", "always" func AutocompleteSystemdRestartOptions(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - return systemdGen.RestartPolicies, cobra.ShellCompDirectiveNoFileComp + return systemdDefine.RestartPolicies, cobra.ShellCompDirectiveNoFileComp } // AutocompleteTrustType - Autocomplete trust type options. diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 2fafbfac1..d1b67d963 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -14,7 +14,7 @@ import ( envLib "github.com/containers/podman/v3/pkg/env" ns "github.com/containers/podman/v3/pkg/namespaces" "github.com/containers/podman/v3/pkg/specgen" - systemdGen "github.com/containers/podman/v3/pkg/systemd/generate" + systemdDefine "github.com/containers/podman/v3/pkg/systemd/define" "github.com/containers/podman/v3/pkg/util" "github.com/docker/go-units" "github.com/opencontainers/runtime-spec/specs-go" @@ -342,8 +342,8 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string return errors.Wrapf(err, "unable to process labels") } - if systemdUnit, exists := osEnv[systemdGen.EnvVariable]; exists { - labels[systemdGen.EnvVariable] = systemdUnit + if systemdUnit, exists := osEnv[systemdDefine.EnvVariable]; exists { + labels[systemdDefine.EnvVariable] = systemdUnit } s.Labels = labels diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go index 2181f850b..fcbcb6722 100644 --- a/cmd/podman/networks/list.go +++ b/cmd/podman/networks/list.go @@ -12,8 +12,8 @@ import ( "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/validate" - "github.com/containers/podman/v3/libpod/network" "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/network" "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" diff --git a/cmd/podman/parse/filters.go b/cmd/podman/parse/filters.go new file mode 100644 index 000000000..8a10f2a97 --- /dev/null +++ b/cmd/podman/parse/filters.go @@ -0,0 +1,20 @@ +package parse + +import ( + "net/url" + "strings" + + "github.com/pkg/errors" +) + +func FilterArgumentsIntoFilters(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/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index dcb3316f0..136c15304 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -8,11 +8,11 @@ import ( "strings" "github.com/containers/common/pkg/completion" + "github.com/containers/podman/v3/cmd/podman/parse" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/utils" "github.com/containers/podman/v3/cmd/podman/validate" "github.com/containers/podman/v3/pkg/domain/entities" - dfilters "github.com/containers/podman/v3/pkg/domain/filters" "github.com/docker/go-units" "github.com/spf13/cobra" ) @@ -80,7 +80,7 @@ Are you sure you want to continue? [y/N] `, volumeString) } } - pruneOptions.Filters, err = dfilters.ParseFilterArgumentsIntoFilters(filters) + pruneOptions.Filters, err = parse.FilterArgumentsIntoFilters(filters) if err != nil { return err } diff --git a/cmd/podman/volumes/prune.go b/cmd/podman/volumes/prune.go index 8f78d0bae..8e190b870 100644 --- a/cmd/podman/volumes/prune.go +++ b/cmd/podman/volumes/prune.go @@ -9,11 +9,11 @@ import ( "github.com/containers/common/pkg/completion" "github.com/containers/podman/v3/cmd/podman/common" + "github.com/containers/podman/v3/cmd/podman/parse" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/utils" "github.com/containers/podman/v3/cmd/podman/validate" "github.com/containers/podman/v3/pkg/domain/entities" - "github.com/containers/podman/v3/pkg/domain/filters" "github.com/spf13/cobra" ) @@ -58,14 +58,14 @@ func prune(cmd *cobra.Command, args []string) error { if err != nil { return err } - pruneOptions.Filters, err = filters.ParseFilterArgumentsIntoFilters(filter) + pruneOptions.Filters, err = parse.FilterArgumentsIntoFilters(filter) if !force { reader := bufio.NewReader(os.Stdin) fmt.Println("WARNING! This will remove all volumes not used by at least one container. The following volumes will be removed:") if err != nil { return err } - listOptions.Filter, err = filters.ParseFilterArgumentsIntoFilters(filter) + listOptions.Filter, err = parse.FilterArgumentsIntoFilters(filter) if err != nil { return err } |