@@ -2,6 +2,7 @@ package main
2
2
3
3
import (
4
4
"context"
5
+ "errors"
5
6
"fmt"
6
7
"io"
7
8
"os"
@@ -21,7 +22,6 @@ import (
21
22
platformsignals "github.com/docker/cli/cmd/docker/internal/signals"
22
23
"github.com/docker/docker/api/types/versions"
23
24
"github.com/docker/docker/errdefs"
24
- "github.com/pkg/errors"
25
25
"github.com/sirupsen/logrus"
26
26
"github.com/spf13/cobra"
27
27
"github.com/spf13/pflag"
@@ -203,7 +203,7 @@ func setupHelpCommand(dockerCli command.Cli, rootCmd, helpCmd *cobra.Command) {
203
203
return helpcmd .Run ()
204
204
}
205
205
if ! pluginmanager .IsNotFound (err ) {
206
- return errors .Errorf ("unknown help topic: %v" , strings .Join (args , " " ))
206
+ return fmt .Errorf ("unknown help topic: %v" , strings .Join (args , " " ))
207
207
}
208
208
}
209
209
if origRunE != nil {
@@ -593,7 +593,7 @@ func isSupported(cmd *cobra.Command, details versionDetails) error {
593
593
}
594
594
595
595
func areFlagsSupported (cmd * cobra.Command , details versionDetails ) error {
596
- errs := [] string {}
596
+ var errs [] error
597
597
598
598
cmd .Flags ().VisitAll (func (f * pflag.Flag ) {
599
599
if ! f .Changed || len (f .Annotations ) == 0 {
@@ -612,22 +612,19 @@ func areFlagsSupported(cmd *cobra.Command, details versionDetails) error {
612
612
return
613
613
}
614
614
if _ , ok := f .Annotations ["ostype" ]; ok && ! isOSTypeSupported (f , details .ServerInfo ().OSType ) {
615
- errs = append (errs , fmt .Sprintf (
615
+ errs = append (errs , fmt .Errorf (
616
616
`"--%s" is only supported on a Docker daemon running on %s, but the Docker daemon is running on %s` ,
617
617
f .Name ,
618
618
getFlagAnnotation (f , "ostype" ), details .ServerInfo ().OSType ),
619
619
)
620
620
return
621
621
}
622
622
if _ , ok := f .Annotations ["experimental" ]; ok && ! details .ServerInfo ().HasExperimental {
623
- errs = append (errs , fmt .Sprintf (`"--%s" is only supported on a Docker daemon with experimental features enabled` , f .Name ))
623
+ errs = append (errs , fmt .Errorf (`"--%s" is only supported on a Docker daemon with experimental features enabled` , f .Name ))
624
624
}
625
625
// buildkit-specific flags are noop when buildkit is not enabled, so we do not add an error in that case
626
626
})
627
- if len (errs ) > 0 {
628
- return errors .New (strings .Join (errs , "\n " ))
629
- }
630
- return nil
627
+ return errors .Join (errs ... )
631
628
}
632
629
633
630
// Check recursively so that, e.g., `docker stack ls` returns the same output as `docker stack`
0 commit comments