summaryrefslogtreecommitdiff
path: root/cmd/podman/parse
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@redhat.com>2022-06-30 10:05:44 +0200
committerSascha Grunert <sgrunert@redhat.com>2022-06-30 12:58:57 +0200
commite8adec5f41388916b0f2206dc898a5587d51467c (patch)
tree856d4c6e84366560554bb91c5a0c33e0c0e29509 /cmd/podman/parse
parent3426d56b92be2ac1c3cc62fc578e9cb6d64aca81 (diff)
downloadpodman-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/parse')
-rw-r--r--cmd/podman/parse/filters.go5
-rw-r--r--cmd/podman/parse/net.go14
2 files changed, 8 insertions, 11 deletions
diff --git a/cmd/podman/parse/filters.go b/cmd/podman/parse/filters.go
index 8a10f2a97..e4ab942af 100644
--- a/cmd/podman/parse/filters.go
+++ b/cmd/podman/parse/filters.go
@@ -1,10 +1,9 @@
package parse
import (
+ "fmt"
"net/url"
"strings"
-
- "github.com/pkg/errors"
)
func FilterArgumentsIntoFilters(filters []string) (url.Values, error) {
@@ -12,7 +11,7 @@ func FilterArgumentsIntoFilters(filters []string) (url.Values, error) {
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)
+ return parsedFilters, fmt.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
}
parsedFilters.Add(t[0], t[1])
}
diff --git a/cmd/podman/parse/net.go b/cmd/podman/parse/net.go
index ba70c7ba5..9228c7127 100644
--- a/cmd/podman/parse/net.go
+++ b/cmd/podman/parse/net.go
@@ -10,8 +10,6 @@ import (
"os"
"regexp"
"strings"
-
- "github.com/pkg/errors"
)
const (
@@ -81,7 +79,7 @@ func GetAllLabels(labelFile, inputLabels []string) (map[string]string, error) {
for _, label := range inputLabels {
split := strings.SplitN(label, "=", 2)
if split[0] == "" {
- return nil, errors.Errorf("invalid label format: %q", label)
+ return nil, fmt.Errorf("invalid label format: %q", label)
}
value := ""
if len(split) > 1 {
@@ -97,13 +95,13 @@ func parseEnvOrLabel(env map[string]string, line, configType string) error {
// catch invalid variables such as "=" or "=A"
if data[0] == "" {
- return errors.Errorf("invalid environment variable: %q", line)
+ return fmt.Errorf("invalid environment variable: %q", line)
}
// trim the front of a variable, but nothing else
name := strings.TrimLeft(data[0], whiteSpaces)
if strings.ContainsAny(name, whiteSpaces) {
- return errors.Errorf("name %q has white spaces, poorly formatted name", name)
+ return fmt.Errorf("name %q has white spaces, poorly formatted name", name)
}
if len(data) > 1 {
@@ -157,7 +155,7 @@ func parseEnvOrLabelFile(envOrLabel map[string]string, filename, configType stri
// as it is currently not supported
func ValidateFileName(filename string) error {
if strings.Contains(filename, ":") {
- return errors.Errorf("invalid filename (should not contain ':') %q", filename)
+ return fmt.Errorf("invalid filename (should not contain ':') %q", filename)
}
return nil
}
@@ -166,10 +164,10 @@ func ValidateFileName(filename string) error {
func ValidURL(urlStr string) error {
url, err := url.ParseRequestURI(urlStr)
if err != nil {
- return errors.Wrapf(err, "invalid url %q", urlStr)
+ return fmt.Errorf("invalid url %q: %w", urlStr, err)
}
if url.Scheme == "" {
- return errors.Errorf("invalid url %q: missing scheme", urlStr)
+ return fmt.Errorf("invalid url %q: missing scheme", urlStr)
}
return nil
}