Skip to content

Commit 11d4af2

Browse files
authored
Merge pull request kubernetes#87344 from apelisse/improve-missing-diff-binary-error
Improve error message when diff binary is not in PATH
2 parents f256c02 + c1a4cd9 commit 11d4af2

File tree

1 file changed

+7
-3
lines changed
  • staging/src/k8s.io/kubectl/pkg/cmd/diff

1 file changed

+7
-3
lines changed

staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ type DiffProgram struct {
130130
genericclioptions.IOStreams
131131
}
132132

133-
func (d *DiffProgram) getCommand(args ...string) exec.Cmd {
133+
func (d *DiffProgram) getCommand(args ...string) (string, exec.Cmd) {
134134
diff := ""
135135
if envDiff := os.Getenv("KUBECTL_EXTERNAL_DIFF"); envDiff != "" {
136136
diff = envDiff
@@ -143,12 +143,16 @@ func (d *DiffProgram) getCommand(args ...string) exec.Cmd {
143143
cmd.SetStdout(d.Out)
144144
cmd.SetStderr(d.ErrOut)
145145

146-
return cmd
146+
return diff, cmd
147147
}
148148

149149
// Run runs the detected diff program. `from` and `to` are the directory to diff.
150150
func (d *DiffProgram) Run(from, to string) error {
151-
return d.getCommand(from, to).Run()
151+
diff, cmd := d.getCommand(from, to)
152+
if err := cmd.Run(); err != nil {
153+
return fmt.Errorf("failed to run %q: %v", diff, err)
154+
}
155+
return nil
152156
}
153157

154158
// Printer is used to print an object.

0 commit comments

Comments
 (0)