From 527e66fc2829917444d874771142fdd834feb8d6 Mon Sep 17 00:00:00 2001 From: zhouya0 Date: Tue, 4 Feb 2020 17:22:23 +0800 Subject: [PATCH] Add kubectl diff exit code doc --- .../diffing_local_and_remote_resources.md | 14 ++++++++++++++ staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/kubectl/docs/book/pages/app_composition_and_deployment/diffing_local_and_remote_resources.md b/staging/src/k8s.io/kubectl/docs/book/pages/app_composition_and_deployment/diffing_local_and_remote_resources.md index 1484f3a6afe..684e37f6854 100644 --- a/staging/src/k8s.io/kubectl/docs/book/pages/app_composition_and_deployment/diffing_local_and_remote_resources.md +++ b/staging/src/k8s.io/kubectl/docs/book/pages/app_composition_and_deployment/diffing_local_and_remote_resources.md @@ -42,3 +42,17 @@ export KUBECTL_EXTERNAL_DIFF=meld; kubectl diff -k ./dir/ {% endmethod %} +{% method %} +## Exit status +The following exit values shall be returned: + + `0` +No differences were found. + `1` +Differences were found. + `>1` +Kubectl or diff failed with an error. + +**Note:** `KUBECTL_EXTERNAL_DIFF`, if used, is expected to follow that convention. + +{% endmethod %} \ No newline at end of file diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go b/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go index 139f33a72c5..93c67e07c2f 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go @@ -56,7 +56,18 @@ var ( KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own diff command. By default, the "diff" command available in your path will be - run with "-u" (unified diff) and "-N" (treat absent files as empty) options.`)) + run with "-u" (unified diff) and "-N" (treat absent files as empty) options. + + Exit status: + 0 + No differences were found. + 1 + Differences were found. + >1 + Kubectl or diff failed with an error. + + Note: KUBECTL_EXTERNAL_DIFF, if used, is expected to follow that convention.`)) + diffExample = templates.Examples(i18n.T(` # Diff resources included in pod.json. kubectl diff -f pod.json