File output flag for writing built images to a specified file#2476
File output flag for writing built images to a specified file#2476priyawadhwa merged 6 commits intoGoogleContainerTools:masterfrom
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.
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.
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
priyawadhwa
left a comment
There was a problem hiding this comment.
looks good to me! could you add a unit test, maybe to TestQuietFlag or write a new one?
| --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.
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.
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.