kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.85k stars 921 forks source link

Add KUBECTL_EXTERNAL_DIFF_OPTIONS env var to set custom diff command options #937

Closed julienvey closed 3 years ago

julienvey commented 4 years ago

What would you like to be added:

I'd like an environment variable KUBECTL_EXTERNAL_DIFF_OPTIONS to be added in order to be able to customize the options when using a diff command other than diff when using kubectl

The related part of the code https://github.com/kubernetes/kubectl/blob/f00cf713934555e6edd635bd7477f028056eda50/pkg/cmd/diff/diff.go#L168

Why is this needed:

When using the default diff command, the options -u and -N are set by default. I'd like to have these same options when using colordiff, and also be able to add any other options that might be necessary

dougsland commented 4 years ago

I think make sense. Let me try to prepare a patch.

dougsland commented 4 years ago

/assign

dougsland commented 4 years ago

With the provided patch the following commands work:

 $ export KUBECTL_EXTERNAL_DIFF="colordiff -N -u"
 $ kubectl diff -f filename.yaml  
eddiezane commented 4 years ago

/assign @seans3

seans3 commented 4 years ago

/triage accepted

dougsland commented 3 years ago

patch is merged, thanks for the report. /close

k8s-ci-robot commented 3 years ago

@dougsland: Closing this issue.

In response to [this](https://github.com/kubernetes/kubectl/issues/937#issuecomment-755830715): >patch is merged, thanks for the report. >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.