diff options
| author | Kubernetes Submit Queue <k8s-merge-robot@users.noreply.github.com> | 2017-10-10 14:26:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-10 14:26:06 -0700 |
| commit | 4f4560659c8ad03c1b3c4bf204512d38fa94d791 (patch) | |
| tree | 01687da8602813e9a66ae442caa7fdd8bc42123e | |
| parent | da223908b764900666bd7b19c0b65c6ab5b4e093 (diff) | |
| parent | 1c7447539b8ac3c35ed0f77bacb23db41f598f29 (diff) | |
Merge pull request #1165 from shiywang/cli
Automatic merge from submit-queue.
add draft exit code to kubectl-conventions
@fabianofranz @smarterclayton @pwittrock @kubernetes/sig-cli-maintainers
| -rw-r--r-- | contributors/devel/kubectl-conventions.md | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/contributors/devel/kubectl-conventions.md b/contributors/devel/kubectl-conventions.md index 6b495718..d309eab6 100644 --- a/contributors/devel/kubectl-conventions.md +++ b/contributors/devel/kubectl-conventions.md @@ -15,6 +15,7 @@ Updated: 3/23/2017 - [Documentation conventions](#documentation-conventions) - [kubectl Factory conventions](#kubectl-Factory-conventions) - [Command implementation conventions](#command-implementation-conventions) + - [Exit code conventions](#exit-code-conventions) - [Generators](#generators) <!-- END MUNGE: GENERATED_TOC --> @@ -375,6 +376,21 @@ this is not a mandatory structure and not every command is implemented this way, but this is a nice convention so try to be compliant with it. As an example, have a look at how [kubectl logs](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/logs.go) is implemented. +## Exit code conventions + +Generally, for all the command exit code, result of `zero` means success and `non-zero` means errors. + +For idempotent ("make-it-so") commands, we should return `zero` when success even if no changes were provided, user can request treating "make-it-so" as "already-so" via flag `--error-unchanged` to make it return `non-zero` exit code. + +For non-idempotent ("already-so") commands, we should return `non-zero` by default, user can request treating "already-so" as "make-it-so" via flag `--ignore-unchanged` to make it return `zero` exit code. + + +| Exit Code Number | Meaning | Enable | +| :--- | :--- | :--- | +| 0 | Command exited success | By default, By flag `--ignore-unchanged` | +| 1 | Command exited for general errors | By default | +| 3 | Command was successful, but the user requested a distinct exit code when no change was made | By flag `--error-unchanged`| + ## Generators Generators are kubectl commands that generate resources based on a set of inputs |
