You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-cli/2551-return-code-normalization/README.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,9 +155,8 @@ To enable the feature, the value must be non-empty, and not equal `0`, or `false
155
155
## Design Details
156
156
157
157
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.
161
160
162
161
One thing that should be done is map all the error codes/ints as constants in some file, so they can be automatically
163
162
documented.
@@ -215,10 +214,10 @@ call to the old checkErr or the new function according to the value of the Envir
215
214
### Creating new error parser functions
216
215
217
216
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
220
219
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.
222
221
223
222
The pro of this approach is that we can re-develop everything controlling the behavior.
224
223
@@ -236,7 +235,7 @@ There's an Hybrid approach that can be used:
236
235
* For the steps that run on the client side, create a new function that does an early exit/return with
237
236
an well known exit code that will be used for all client side operations (no difference between yaml
238
237
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
240
239
with the old behavior, depending on the Environment Variable described above
0 commit comments