diff options
author | Sascha Grunert <sgrunert@redhat.com> | 2022-06-30 10:05:44 +0200 |
---|---|---|
committer | Sascha Grunert <sgrunert@redhat.com> | 2022-06-30 12:58:57 +0200 |
commit | e8adec5f41388916b0f2206dc898a5587d51467c (patch) | |
tree | 856d4c6e84366560554bb91c5a0c33e0c0e29509 /cmd/podman/validate | |
parent | 3426d56b92be2ac1c3cc62fc578e9cb6d64aca81 (diff) | |
download | podman-e8adec5f41388916b0f2206dc898a5587d51467c.tar.gz podman-e8adec5f41388916b0f2206dc898a5587d51467c.tar.bz2 podman-e8adec5f41388916b0f2206dc898a5587d51467c.zip |
cmd/podman: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Diffstat (limited to 'cmd/podman/validate')
-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 } |