Skip to content

Commit bd71944

Browse files
author
Ross Peoples
committed
More generic wording for validation and execution
1 parent 7e45a2f commit bd71944

File tree

1 file changed

+6
-7
lines changed
  • keps/sig-cli/2551-return-code-normalization

1 file changed

+6
-7
lines changed

keps/sig-cli/2551-return-code-normalization/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,8 @@ To enable the feature, the value must be non-empty, and not equal `0`, or `false
155155
## Design Details
156156

157157
The majority of commands already are organized as the following:
158-
* Run Complete to complete missing information with defaults. This runs on the client side
159-
* Run Validation to check command syntax and missing arguments. This runs on the client side
160-
* Execute command itself. This might run on the client side, be dry-run, run an external command or call the APIServer.
158+
* Validation: check `Options` and set defaults. This runs on the client side.
159+
* Execute based on `Options`. This might run on the client side, be dry-run, run an external command or call the APIServer.
161160

162161
One thing that should be done is map all the error codes/ints as constants in some file, so they can be automatically
163162
documented.
@@ -215,10 +214,10 @@ call to the old checkErr or the new function according to the value of the Envir
215214
### Creating new error parser functions
216215

217216
Another design solution is to create helper functions for each steps:
218-
* When running Complete, Validate or other client side steps, call cmdutil.CheckClientErr(err) and exits with some well defined client error code, mapped to ErrorCodeClient
219-
* When running the Run* step, delegate the returning error to a new function (cmdutil.CheckRunErr) that
217+
* When running validation, call cmdutil.CheckValidationErr(err) and exits with some well defined client error code, mapped to ErrorCodeClient
218+
* When executing, delegate the returning error to a new function (cmdutil.CheckExecutionErr) that
220219
can assess if the error contains some APIError (like forbidden, not found) or Client Error and return the proper
221-
error. Any new Return Code from Run step should be added to errors.go and the case predicted here.
220+
error. Any new Return Code from execution step should be added to errors.go and the case predicted here.
222221

223222
The pro of this approach is that we can re-develop everything controlling the behavior.
224223

@@ -236,7 +235,7 @@ There's an Hybrid approach that can be used:
236235
* For the steps that run on the client side, create a new function that does an early exit/return with
237236
an well known exit code that will be used for all client side operations (no difference between yaml
238237
validation, missing flag, etc)
239-
* For the Run* step, call CheckErr, that might delegate the error validation to a new function or follow
238+
* For the execution step, call CheckErr, that might delegate the error validation to a new function or follow
240239
with the old behavior, depending on the Environment Variable described above
241240

242241
```

0 commit comments

Comments
 (0)