-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
File output flag for writing built images to a specified file #2476
File output flag for writing built images to a specified file #2476
Conversation
Codecov Report
|
This looks good! Few comments
|
cmd/skaffold/app/cmd/build.go
Outdated
cmdOut := flags.BuildOutput{Builds: bRes} | ||
|
||
if buildOutputFlag != "" { | ||
f, err := os.OpenFile(buildOutputFlag, os.O_RDWR|os.O_CREATE, 0755) |
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.
Can you use ioutil.WriteFile like skaffold fix uses
here https://github.com/GoogleContainerTools/skaffold/blob/master/cmd/skaffold/app/cmd/fix.go#L73
if err := ioutil.WriteFile(configFile, newCfg, 0644); err != nil { }
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.
ah ok.
Can you create a bytes.buffer and execute the template there
buildOut bytes.Buffer
t.Execute(buildOut, r)
And the if --quiet is present,
out.Write(buildOut)
if "--file-output" is present,
err := ioutil.WriteFile(buildOutputFlag, buildOut, 0644)
if err != nil {
log.Fatal(err)
}
That ways its cleaner and we do not overwrite out
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.
looks good to me! could you add a unit test, maybe to TestQuietFlag or write a new one?
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.
LGTM!
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.
yay!
@@ -104,6 +104,7 @@ Options: | |||
--cache-file='': Specify the location of the cache file (default $HOME/.skaffold/cache) | |||
-d, --default-repo='': Default repository value (overrides global config) | |||
--enable-rpc=false: Enable gRPC for exposing Skaffold events (true by default for `skaffold dev`) | |||
--file-output='': Filename to write build images to |
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.
Do we still need "Used in conjunction with --quiet flag" for -o, --output
? I guess from now on that flag even applies without quiet mode?!
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 that should still be there, but be updated to say "Used in conjunction with --quiet or --file-output", since those are the only two flags whose output it effects.
Is there something off with the documentation? It works fine with |
--output is actually the flag used to format the output of --quiet (and now --file-output as well). The naming is a bit confusing, sorry about that. Running skaffold build --help should show documentation for both --output and --file-output. |
This is essentially the same as running skaffold build --quiet > file.out, but doesn't silence the standard output from skaffold.