diff --git a/internal/util/cmdutil/cmdutil.go b/internal/util/cmdutil/cmdutil.go index 65b8f4c2be..2b86d29afe 100644 --- a/internal/util/cmdutil/cmdutil.go +++ b/internal/util/cmdutil/cmdutil.go @@ -23,7 +23,6 @@ import ( "path/filepath" "strings" - "github.com/GoogleContainerTools/kpt/internal/errors" "github.com/GoogleContainerTools/kpt/internal/fnruntime" "github.com/spf13/cobra" "sigs.k8s.io/kustomize/kyaml/kio" @@ -85,10 +84,8 @@ func ResolveAbsAndRelPaths(path string) (string, string, error) { // DockerCmdAvailable runs `docker ps` to check that the docker command is // available, and returns an error with installation instructions if it is not func DockerCmdAvailable() error { - const op errors.Op = "docker.check" - - suggestedText := `Docker is required to run this command. -To install docker, follow the instructions at https://docs.docker.com/get-docker/ + suggestedText := `docker must be running to use this command +To install docker, follow the instructions at https://docs.docker.com/get-docker/. ` buffer := &bytes.Buffer{} @@ -96,7 +93,7 @@ To install docker, follow the instructions at https://docs.docker.com/get-docker cmd.Stderr = buffer err := cmd.Run() if err != nil { - return errors.E(op, fmt.Errorf("%s", suggestedText)) + return fmt.Errorf("%s", suggestedText) } return nil } diff --git a/thirdparty/cmdconfig/commands/cmdeval/cmdeval.go b/thirdparty/cmdconfig/commands/cmdeval/cmdeval.go index 7a077e54a1..96fef8957d 100644 --- a/thirdparty/cmdconfig/commands/cmdeval/cmdeval.go +++ b/thirdparty/cmdconfig/commands/cmdeval/cmdeval.go @@ -233,6 +233,12 @@ func (r *EvalFnRunner) preRunE(c *cobra.Command, args []string) error { if r.Image == "" && r.ExecPath == "" { return errors.Errorf("must specify --image or --exec-path") } + if r.Image != "" { + err := cmdutil.DockerCmdAvailable() + if err != nil { + return err + } + } if err := cmdutil.ValidateImagePullPolicyValue(r.ImagePullPolicy); err != nil { return err }