-
Notifications
You must be signed in to change notification settings - Fork 215
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 output-file flag #60
Conversation
0392bfe
to
38ddba2
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.
This looks really promising, thanks for getting this in!
main.go
Outdated
|
||
client := &http.Client{} | ||
resp, err := client.Do(req) | ||
fmt.Println(string(y)) |
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.
I think a call to os.Stdout.Write
could be better here. https://godoc.org/os#File.Write
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.
Done
main.go
Outdated
} | ||
defer resp.Body.Close() | ||
|
||
body, _ := ioutil.ReadAll(resp.Body) |
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 should likely not ignore the potential error in the response from ioutil.ReadAll
(https://golang.org/pkg/io/ioutil/#ReadAll)
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.
That's what I get for copy/pasting from Stack Overflow
k, _ := kube.CreateKubeAPI() | ||
auditData, err := validator.RunAudit(c, k) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if destination != "" { | ||
jsonData, err := json.Marshal(auditData) | ||
if outputURL == "" && outputFile == "" { |
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 this whole section be restructured to something like:
if outputURL != "" {
# send to url
} else if outputFile != "" {
# send to file
} else {
# send to stdout
}
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.
That's I originally had it, but
- There's some common logic for
outputURL
andoutputFile
for serializing to JSON - We need to output to both file and URL in some cases (e.g. the hosted version needs this)
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.
👍 that makes a lot of sense
No description provided.