add draft exit code to kubectl-conventions, add some redundancy and parallelism

This commit is contained in:
Shiyang Wang 2017-10-09 17:41:45 +08:00
parent 33c4b2d55b
commit 1c7447539b
1 changed files with 16 additions and 0 deletions

View File

@ -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