diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-06-30 09:58:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 09:58:52 -0400 |
commit | 3e8ab312395b32d0b43f1ac82adf53439b012893 (patch) | |
tree | b8024f94b0f7446f6779c5d6e83bc6697c010387 /cmd/podman/validate/args.go | |
parent | aa109ae0f058060466b61d01571e37b7cc718b9a (diff) | |
parent | e8adec5f41388916b0f2206dc898a5587d51467c (diff) | |
download | podman-3e8ab312395b32d0b43f1ac82adf53439b012893.tar.gz podman-3e8ab312395b32d0b43f1ac82adf53439b012893.tar.bz2 podman-3e8ab312395b32d0b43f1ac82adf53439b012893.zip |
Merge pull request #14785 from saschagrunert/cmd-podman-errors
cmd/podman: switch to golang native error wrapping
Diffstat (limited to 'cmd/podman/validate/args.go')
-rw-r--r-- | cmd/podman/validate/args.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/cmd/podman/validate/args.go b/cmd/podman/validate/args.go index ae405e0e5..39eedca64 100644 --- a/cmd/podman/validate/args.go +++ b/cmd/podman/validate/args.go @@ -1,12 +1,12 @@ package validate import ( + "errors" "fmt" "strconv" "strings" "github.com/containers/podman/v4/cmd/podman/registry" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -23,12 +23,12 @@ func SubCommandExists(cmd *cobra.Command, args []string) error { if len(args) > 0 { suggestions := cmd.SuggestionsFor(args[0]) if len(suggestions) == 0 { - return errors.Errorf("unrecognized command `%[1]s %[2]s`\nTry '%[1]s --help' for more information", cmd.CommandPath(), args[0]) + return fmt.Errorf("unrecognized command `%[1]s %[2]s`\nTry '%[1]s --help' for more information", cmd.CommandPath(), args[0]) } - return errors.Errorf("unrecognized command `%[1]s %[2]s`\n\nDid you mean this?\n\t%[3]s\n\nTry '%[1]s --help' for more information", cmd.CommandPath(), args[0], strings.Join(suggestions, "\n\t")) + return fmt.Errorf("unrecognized command `%[1]s %[2]s`\n\nDid you mean this?\n\t%[3]s\n\nTry '%[1]s --help' for more information", cmd.CommandPath(), args[0], strings.Join(suggestions, "\n\t")) } cmd.Help() //nolint: errcheck - return errors.Errorf("missing command '%[1]s COMMAND'", cmd.CommandPath()) + return fmt.Errorf("missing command '%[1]s COMMAND'", cmd.CommandPath()) } // IDOrLatestArgs used to validate a nameOrId was provided or the "--latest" flag @@ -44,7 +44,7 @@ func IDOrLatestArgs(cmd *cobra.Command, args []string) error { return fmt.Errorf("%q requires a name, id, or the \"--latest\" flag", cmd.CommandPath()) } if len(args) > 0 && given { - return fmt.Errorf("--latest and containers cannot be used together") + return errors.New("--latest and containers cannot be used together") } } return nil @@ -75,7 +75,7 @@ func CheckAllLatestAndIDFile(c *cobra.Command, args []string, ignoreArgLen bool, if idFileFlag == "" { return errors.New("unable to look up values for 'latest' or 'all'") } else if c.Flags().Lookup(idFileFlag) == nil { - return errors.Errorf("unable to look up values for 'latest', 'all', or '%s'", idFileFlag) + return fmt.Errorf("unable to look up values for 'latest', 'all', or '%s'", idFileFlag) } } } @@ -87,13 +87,13 @@ func CheckAllLatestAndIDFile(c *cobra.Command, args []string, ignoreArgLen bool, } if specifiedIDFile && (specifiedAll || specifiedLatest) { - return errors.Errorf("--all, --latest, and --%s cannot be used together", idFileFlag) + return fmt.Errorf("--all, --latest, and --%s cannot be used together", idFileFlag) } else if specifiedAll && specifiedLatest { - return errors.Errorf("--all and --latest cannot be used together") + return errors.New("--all and --latest cannot be used together") } if (argLen > 0) && specifiedAll { - return errors.Errorf("no arguments are needed with --all") + return errors.New("no arguments are needed with --all") } if ignoreArgLen { @@ -102,9 +102,9 @@ func CheckAllLatestAndIDFile(c *cobra.Command, args []string, ignoreArgLen bool, if argLen > 0 { if specifiedLatest { - return errors.Errorf("--latest and containers cannot be used together") + return errors.New("--latest and containers cannot be used together") } else if idFileFlag != "" && (specifiedLatest || specifiedIDFile) { - return errors.Errorf("no arguments are needed with --latest or --%s", idFileFlag) + return fmt.Errorf("no arguments are needed with --latest or --%s", idFileFlag) } } @@ -113,7 +113,7 @@ func CheckAllLatestAndIDFile(c *cobra.Command, args []string, ignoreArgLen bool, } if argLen < 1 && !specifiedAll && !specifiedLatest && !specifiedIDFile { - return errors.Errorf("you must provide at least one name or id") + return errors.New("you must provide at least one name or id") } return nil } |