44package stack
55
66import (
7+ "errors"
78 "fmt"
89 "io"
910 "os"
@@ -17,7 +18,6 @@ import (
1718 "github.com/docker/cli/cli/compose/loader"
1819 "github.com/docker/cli/cli/compose/schema"
1920 composetypes "github.com/docker/cli/cli/compose/types"
20- "github.com/pkg/errors"
2121)
2222
2323// loadComposeFile parse the composefile specified in the cli and returns its configOptions and version.
@@ -30,9 +30,10 @@ func loadComposeFile(streams command.Streams, opts deployOptions) (*composetypes
3030 dicts := getDictsFrom (configDetails .ConfigFiles )
3131 config , err := loader .Load (configDetails )
3232 if err != nil {
33- if fpe , ok := err .(* loader.ForbiddenPropertiesError ); ok {
33+ var fpe * loader.ForbiddenPropertiesError
34+ if errors .As (err , & fpe ) {
3435 // this error is intentionally formatted multi-line
35- return nil , errors .Errorf ("Compose file contains unsupported options:\n \n %s\n " , propertyWarnings (fpe .Properties ))
36+ return nil , fmt .Errorf ("compose file contains unsupported options:\n \n %s\n " , propertyWarnings (fpe .Properties )) //nolint:staticcheck // ignore ST1005
3637 }
3738
3839 return nil , err
@@ -53,10 +54,10 @@ func loadComposeFile(streams command.Streams, opts deployOptions) (*composetypes
5354 // Validate if each service has a valid image-reference.
5455 for _ , svc := range config .Services {
5556 if svc .Image == "" {
56- return nil , errors .Errorf ("invalid image reference for service %s: no image specified" , svc .Name )
57+ return nil , fmt .Errorf ("invalid image reference for service %s: no image specified" , svc .Name )
5758 }
5859 if _ , err := reference .ParseAnyReference (svc .Image ); err != nil {
59- return nil , errors . Wrapf ( err , "invalid image reference for service %s" , svc .Name )
60+ return nil , fmt . Errorf ( "invalid image reference for service %s: %w " , svc .Name , err )
6061 }
6162 }
6263
@@ -87,7 +88,7 @@ func getConfigDetails(composefiles []string, stdin io.Reader) (composetypes.Conf
8788 var details composetypes.ConfigDetails
8889
8990 if len (composefiles ) == 0 {
90- return details , errors .New ("Specify a Compose file (with --compose-file)" )
91+ return details , errors .New ("specify a Compose file (with --compose-file)" )
9192 }
9293
9394 if composefiles [0 ] == "-" && len (composefiles ) == 1 {
@@ -133,7 +134,7 @@ func buildEnvironment(env []string) (map[string]string, error) {
133134
134135 k , v , ok := strings .Cut (s , "=" )
135136 if ! ok || k == "" {
136- return result , errors .Errorf ("unexpected environment variable '%s'" , s )
137+ return result , fmt .Errorf ("unexpected environment variable '%s'" , s )
137138 }
138139 // value may be set, but empty if "s" is like "K=", not "K".
139140 result [k ] = v
0 commit comments