-
Notifications
You must be signed in to change notification settings - Fork 303
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
Add report utils for gke-diagnoser to support json output #2020
Add report utils for gke-diagnoser to support json output #2020
Conversation
Hi @songrx1997. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @swetharepakula |
/ok-to-test |
cmd/gke-diagnoser/app/util/report.go
Outdated
|
||
// Resource represents the a resource of the cluster and all the checks done on it | ||
type Resource struct { | ||
Type string `json:"type"` |
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.
This is called Kind in Kubernetes not Type
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.
Updated, thanks!
cmd/gke-diagnoser/app/util/report.go
Outdated
type Check struct { | ||
Name string `json:"name"` | ||
Msg string `json:"msg"` | ||
Res string `json:"res"` |
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.
Please don't use abbreviations unless there is a good reason. This makes it hard to read and understand.
Message
Resource
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.
Updated, thanks!
cmd/gke-diagnoser/app/util/report.go
Outdated
Res string `json:"res"` | ||
} | ||
|
||
func JsonReport(report Report) string { |
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.
report should be a pointer (report *Report)
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.
Updated, thanks!
cmd/gke-diagnoser/app/util/report.go
Outdated
func JsonReport(report Report) string { | ||
jsonRaw, err := json.MarshalIndent(report, "", " ") | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Error Marshalling JSON: %s\n", jsonRaw) |
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.
Is this how we are handling errors?
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.
Changed this to return an error and let the caller handle it.
} | ||
|
||
// SupportedOutputs returns a string list of output formats supposed by this package | ||
func SupportedOutputs() []string { |
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.
How is this used?
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.
This will be used by a flag checker to check whether a format is supported.
/hold |
bb14b6e
to
405b663
Compare
405b663
to
c53680e
Compare
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: songrx1997, swetharepakula The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel As the original comments have been addressed, removing the hold |
Add report structs for gke-diagnoser CLI
Add json utils for the output report