mirror of
https://github.com/containers/podman
synced 2024-10-22 10:13:33 +00:00
Merge pull request #8370 from rhatdan/wrap
Remove some more excessive wrapping and stuttering
This commit is contained in:
commit
12de330094
|
@ -592,7 +592,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
|
|||
case "max-size":
|
||||
logSize, err := units.FromHumanSize(split[1])
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "%s is not a valid option", o)
|
||||
return err
|
||||
}
|
||||
s.LogConfiguration.Size = logSize
|
||||
default:
|
||||
|
@ -662,7 +662,7 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
|
|||
}
|
||||
intervalDuration, err := time.ParseDuration(interval)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "invalid healthcheck-interval %s ", interval)
|
||||
return nil, errors.Wrapf(err, "invalid healthcheck-interval")
|
||||
}
|
||||
|
||||
hc.Interval = intervalDuration
|
||||
|
@ -673,7 +673,7 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
|
|||
hc.Retries = int(retries)
|
||||
timeoutDuration, err := time.ParseDuration(timeout)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "invalid healthcheck-timeout %s", timeout)
|
||||
return nil, errors.Wrapf(err, "invalid healthcheck-timeout")
|
||||
}
|
||||
if timeoutDuration < time.Duration(1) {
|
||||
return nil, errors.New("healthcheck-timeout must be at least 1 second")
|
||||
|
@ -682,7 +682,7 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
|
|||
|
||||
startPeriodDuration, err := time.ParseDuration(startPeriod)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "invalid healthcheck-start-period %s", startPeriod)
|
||||
return nil, errors.Wrapf(err, "invalid healthcheck-start-period")
|
||||
}
|
||||
if startPeriodDuration < time.Duration(0) {
|
||||
return nil, errors.New("healthcheck-start-period must be 0 seconds or greater")
|
||||
|
|
|
@ -250,7 +250,7 @@ func parseAndValidateRange(portRange string) (uint16, uint16, error) {
|
|||
func parseAndValidatePort(port string) (uint16, error) {
|
||||
num, err := strconv.Atoi(port)
|
||||
if err != nil {
|
||||
return 0, errors.Wrapf(err, "cannot parse %q as a port number", port)
|
||||
return 0, errors.Wrapf(err, "invalid port number")
|
||||
}
|
||||
if num < 1 || num > 65535 {
|
||||
return 0, errors.Errorf("port numbers must be between 1 and 65535 (inclusive), got %d", num)
|
||||
|
|
|
@ -57,7 +57,7 @@ func prune(cmd *cobra.Command, args []string) error {
|
|||
fmt.Print("Are you sure you want to continue? [y/N] ")
|
||||
answer, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error reading input")
|
||||
return err
|
||||
}
|
||||
if strings.ToLower(answer)[0] != 'y' {
|
||||
return nil
|
||||
|
|
|
@ -205,7 +205,7 @@ func run(cmd *cobra.Command, args []string) error {
|
|||
if runRmi {
|
||||
_, rmErrors := registry.ImageEngine().Remove(registry.GetContext(), []string{imageName}, entities.ImageRemoveOptions{})
|
||||
if len(rmErrors) > 0 {
|
||||
logrus.Errorf("%s", errors.Wrapf(errorhandling.JoinErrors(rmErrors), "failed removing image"))
|
||||
logrus.Errorf("%s", errorhandling.JoinErrors(rmErrors))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -353,18 +353,18 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
|||
|
||||
isolation, err := parse.IsolationOption(flags.Isolation)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error parsing ID mapping options")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
usernsOption, idmappingOptions, err := parse.IDMappingOptions(c, isolation)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error parsing ID mapping options")
|
||||
return nil, err
|
||||
}
|
||||
nsValues = append(nsValues, usernsOption...)
|
||||
|
||||
systemContext, err := parse.SystemContextFromOptions(c)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error building system context")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
format := ""
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/utils"
|
||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -60,7 +59,7 @@ WARNING! This will remove all dangling images.
|
|||
Are you sure you want to continue? [y/N] `)
|
||||
answer, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error reading input")
|
||||
return err
|
||||
}
|
||||
if strings.ToLower(answer)[0] != 'y' {
|
||||
return nil
|
||||
|
|
|
@ -58,7 +58,7 @@ func sign(cmd *cobra.Command, args []string) error {
|
|||
if len(signOptions.Directory) > 0 {
|
||||
sigStoreDir = signOptions.Directory
|
||||
if _, err := os.Stat(sigStoreDir); err != nil {
|
||||
return errors.Wrapf(err, "invalid directory %s", sigStoreDir)
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err := registry.ImageEngine().Sign(registry.Context(), args, signOptions)
|
||||
|
|
|
@ -55,7 +55,7 @@ func setTrust(cmd *cobra.Command, args []string) error {
|
|||
|
||||
valid, err := image.IsValidImageURI(args[0])
|
||||
if err != nil || !valid {
|
||||
return errors.Wrapf(err, "invalid image uri %s", args[0])
|
||||
return err
|
||||
}
|
||||
|
||||
if !util.StringInSlice(setOptions.Type, validTrustTypes) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/containers/podman/v2/pkg/util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -116,7 +115,7 @@ func add(cmd *cobra.Command, args []string) error {
|
|||
|
||||
listID, err := registry.ImageEngine().ManifestAdd(context.Background(), manifestAddOpts.ManifestAddOptions)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error adding to manifest list %s", args[0])
|
||||
return err
|
||||
}
|
||||
fmt.Printf("%s\n", listID)
|
||||
return nil
|
||||
|
|
|
@ -73,7 +73,7 @@ func annotate(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
updatedListID, err := registry.ImageEngine().ManifestAnnotate(context.Background(), args, manifestAnnotateOpts)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error removing from manifest list %s", listImageSpec)
|
||||
return err
|
||||
}
|
||||
fmt.Printf("%s\n", updatedListID)
|
||||
return nil
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/common"
|
||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -39,7 +38,7 @@ func init() {
|
|||
func create(cmd *cobra.Command, args []string) error {
|
||||
imageID, err := registry.ImageEngine().ManifestCreate(context.Background(), args[:1], args[1:], manifestCreateOpts)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error creating manifest %s", args[0])
|
||||
return err
|
||||
}
|
||||
fmt.Printf("%s\n", imageID)
|
||||
return nil
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/common"
|
||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -35,7 +34,7 @@ func init() {
|
|||
func inspect(cmd *cobra.Command, args []string) error {
|
||||
buf, err := registry.ImageEngine().ManifestInspect(context.Background(), args[0])
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error inspect manifest %s", args[0])
|
||||
return err
|
||||
}
|
||||
fmt.Printf("%s\n", buf)
|
||||
return nil
|
||||
|
|
|
@ -108,7 +108,7 @@ func push(cmd *cobra.Command, args []string) error {
|
|||
manifestPushOpts.SkipTLSVerify = types.NewOptionalBool(!manifestPushOpts.TLSVerifyCLI)
|
||||
}
|
||||
if err := registry.ImageEngine().ManifestPush(registry.Context(), args, manifestPushOpts.ManifestPushOptions); err != nil {
|
||||
return errors.Wrapf(err, "error pushing manifest %s to %s", listImageSpec, destSpec)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ func create(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
if len(podIDFile) > 0 {
|
||||
if err = ioutil.WriteFile(podIDFile, []byte(response.Id), 0644); err != nil {
|
||||
return errors.Wrapf(err, "failed to write pod ID to file %q", podIDFile)
|
||||
return errors.Wrapf(err, "failed to write pod ID to file")
|
||||
}
|
||||
}
|
||||
fmt.Println(response.Id)
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/utils"
|
||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -51,7 +50,7 @@ func prune(cmd *cobra.Command, args []string) error {
|
|||
fmt.Print("Are you sure you want to continue? [y/N] ")
|
||||
answer, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error reading input")
|
||||
return err
|
||||
}
|
||||
if strings.ToLower(answer)[0] != 'y' {
|
||||
return nil
|
||||
|
|
|
@ -189,8 +189,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
|
|||
if cmd.Flag("cpu-profile").Changed {
|
||||
f, err := os.Create(cfg.CPUProfile)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to create cpu profiling file %s",
|
||||
cfg.CPUProfile)
|
||||
return err
|
||||
}
|
||||
if err := pprof.StartCPUProfile(f); err != nil {
|
||||
return err
|
||||
|
|
|
@ -79,14 +79,14 @@ func add(cmd *cobra.Command, args []string) error {
|
|||
// Default to ssh: schema if none given
|
||||
dest := args[1]
|
||||
if match, err := regexp.Match(schemaPattern, []byte(dest)); err != nil {
|
||||
return errors.Wrapf(err, "internal regex error %q", schemaPattern)
|
||||
return errors.Wrapf(err, "invalid destination")
|
||||
} else if !match {
|
||||
dest = "ssh://" + dest
|
||||
}
|
||||
|
||||
uri, err := url.Parse(dest)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to parse %q", dest)
|
||||
return err
|
||||
}
|
||||
|
||||
if uri.User.Username() == "" {
|
||||
|
@ -109,7 +109,7 @@ func add(cmd *cobra.Command, args []string) error {
|
|||
|
||||
if uri.Path == "" || uri.Path == "/" {
|
||||
if uri.Path, err = getUDS(cmd, uri); err != nil {
|
||||
return errors.Wrapf(err, "failed to connect to %q", uri.String())
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ func getUserInfo(uri *url.URL) (*url.Userinfo, error) {
|
|||
if u, found := os.LookupEnv("_CONTAINERS_ROOTLESS_UID"); found {
|
||||
usr, err = user.LookupId(u)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to find user %q", u)
|
||||
return nil, errors.Wrapf(err, "failed to lookup rootless user")
|
||||
}
|
||||
} else {
|
||||
usr, err = user.Current()
|
||||
|
@ -209,7 +209,7 @@ func getUDS(cmd *cobra.Command, uri *url.URL) (string, error) {
|
|||
}
|
||||
dial, err := ssh.Dial("tcp", uri.Host, cfg)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to connect to %q", uri.Host)
|
||||
return "", errors.Wrapf(err, "failed to connect")
|
||||
}
|
||||
defer dial.Close()
|
||||
|
||||
|
@ -229,7 +229,7 @@ func getUDS(cmd *cobra.Command, uri *url.URL) (string, error) {
|
|||
var buffer bytes.Buffer
|
||||
session.Stdout = &buffer
|
||||
if err := session.Run(run); err != nil {
|
||||
return "", errors.Wrapf(err, "failed to run %q", run)
|
||||
return "", err
|
||||
}
|
||||
|
||||
var info define.Info
|
||||
|
@ -238,7 +238,7 @@ func getUDS(cmd *cobra.Command, uri *url.URL) (string, error) {
|
|||
}
|
||||
|
||||
if info.Host.RemoteSocket == nil || len(info.Host.RemoteSocket.Path) == 0 {
|
||||
return "", fmt.Errorf("remote podman %q failed to report its UDS socket", uri.Host)
|
||||
return "", errors.Errorf("remote podman %q failed to report its UDS socket", uri.Host)
|
||||
}
|
||||
return info.Host.RemoteSocket.Path, nil
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||
"github.com/containers/podman/v2/libpod/events"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -104,7 +103,7 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
|
|||
case doJSON:
|
||||
jsonStr, err := event.ToJSONString()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to format json")
|
||||
return err
|
||||
}
|
||||
fmt.Println(jsonStr)
|
||||
case cmd.Flags().Changed("format"):
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/utils"
|
||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -68,7 +67,7 @@ WARNING! This will remove:
|
|||
Are you sure you want to continue? [y/N] `, volumeString)
|
||||
answer, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error reading input")
|
||||
return err
|
||||
}
|
||||
if strings.ToLower(answer)[0] != 'y' {
|
||||
return nil
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/containers/podman/v2/pkg/domain/infra"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -57,7 +57,7 @@ WARNING! This will remove:
|
|||
Are you sure you want to continue? [y/N] `)
|
||||
answer, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
fmt.Println(errors.Wrapf(err, "error reading input"))
|
||||
logrus.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if strings.ToLower(answer)[0] != 'y' {
|
||||
|
@ -71,13 +71,13 @@ Are you sure you want to continue? [y/N] `)
|
|||
|
||||
engine, err := infra.NewSystemEngine(entities.ResetMode, registry.PodmanConfig())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
logrus.Error(err)
|
||||
os.Exit(125)
|
||||
}
|
||||
defer engine.Shutdown(registry.Context())
|
||||
|
||||
if err := engine.Reset(registry.Context()); err != nil {
|
||||
fmt.Println(err)
|
||||
logrus.Error(err)
|
||||
os.Exit(125)
|
||||
}
|
||||
os.Exit(0)
|
||||
|
|
|
@ -33,7 +33,7 @@ func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entiti
|
|||
address := strings.Join(fields[1:], ":")
|
||||
l, err := net.Listen(fields[0], address)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to create socket %s", opts.URI)
|
||||
return errors.Wrapf(err, "unable to create socket")
|
||||
}
|
||||
listener = &l
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/containers/podman/v2/cmd/podman/utils"
|
||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -53,7 +52,7 @@ func prune(cmd *cobra.Command, args []string) error {
|
|||
fmt.Print("Are you sure you want to continue? [y/N] ")
|
||||
answer, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error reading input")
|
||||
return err
|
||||
}
|
||||
if strings.ToLower(answer)[0] != 'y' {
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue