mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #87344 from apelisse/improve-missing-diff-binary-error
Improve error message when diff binary is not in PATH
This commit is contained in:
commit
11d4af2558
@ -130,7 +130,7 @@ type DiffProgram struct {
|
|||||||
genericclioptions.IOStreams
|
genericclioptions.IOStreams
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DiffProgram) getCommand(args ...string) exec.Cmd {
|
func (d *DiffProgram) getCommand(args ...string) (string, exec.Cmd) {
|
||||||
diff := ""
|
diff := ""
|
||||||
if envDiff := os.Getenv("KUBECTL_EXTERNAL_DIFF"); envDiff != "" {
|
if envDiff := os.Getenv("KUBECTL_EXTERNAL_DIFF"); envDiff != "" {
|
||||||
diff = envDiff
|
diff = envDiff
|
||||||
@ -143,12 +143,16 @@ func (d *DiffProgram) getCommand(args ...string) exec.Cmd {
|
|||||||
cmd.SetStdout(d.Out)
|
cmd.SetStdout(d.Out)
|
||||||
cmd.SetStderr(d.ErrOut)
|
cmd.SetStderr(d.ErrOut)
|
||||||
|
|
||||||
return cmd
|
return diff, cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the detected diff program. `from` and `to` are the directory to diff.
|
// Run runs the detected diff program. `from` and `to` are the directory to diff.
|
||||||
func (d *DiffProgram) Run(from, to string) error {
|
func (d *DiffProgram) Run(from, to string) error {
|
||||||
return d.getCommand(from, to).Run()
|
diff, cmd := d.getCommand(from, to)
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
return fmt.Errorf("failed to run %q: %v", diff, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Printer is used to print an object.
|
// Printer is used to print an object.
|
||||||
|
Loading…
Reference in New Issue
Block a user