-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove leaking logs from SDK #868
base: master
Are you sure you want to change the base?
Conversation
bb4bc30
to
a87570f
Compare
StatusReasonInternalError StatusReason = "InternalError" | ||
|
||
// Status code 401 | ||
StatusReasonUnauthorized StatusReason = "Unauthorized" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be http.StatusUnauthorized? https://golang.org/src/net/http/status.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can but we will have challenge in solving two problems, if we are not using StatusReason
-
When we will have same http status code being returned for different errors. I think we are not doing that right now but will be helpful in future.
-
Since we are only having typed errors for only handful of http status codes, so if API server returns an HTTP response code for which we don't have typed error, we are returning that as
UnknownError
embedding HTTP Response code and reason. We are checking for UnknownError based on HTTP response code. Please go through this file, https://github.com/openfaas/faas-cli/pull/868/files#diff-25e38af31c2b62e171bb1b4e9a70546d19aa8fbd180d435435814962e2912600
If we remove StatusReason, to figure out UnknownError we will have to check for list of all HTTP status for which we have typed error.
a87570f
to
0c9edf9
Compare
This commit removing lekaing logs from deploy API in SDK. It also returns typed errors from API resoponse and allows as to check for some custom errors which functions like `IsNotFound` or `IsUnauthorized`. This also updates DeployFuntion API to return a typed response and `http.Response`. Signed-off-by: Vivek Singh <[email protected]>
0c9edf9
to
4f81de9
Compare
|
||
if spec.Update == true && statusCode == http.StatusNotFound { | ||
if spec.Update == true && IsNotFound(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of checking types error.
@@ -24,3 +27,13 @@ func checkTLSInsecure(gateway string, tlsInsecure bool) string { | |||
} | |||
return "" | |||
} | |||
|
|||
//actionableErrorMessage print actionable error message based on APIError check | |||
func actionableErrorMessage(err error) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A generic error message functions which can be used in all commands to print error message for generic APIError like 403, 500 etc
This commit removes leaking logs from the SDK (proxy package) of the CLI by removing
custom print statements within proxy package. It updates method signature for
DeployFunction which now returns deployOutput text along with status code.
Fixes: #853
Signed-off-by: Vivek Singh [email protected]
Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist:
git commit -s