Save stderr since it may become nil

pull/6/head
Michael Fraenkel 2016-09-07 13:25:35 -04:00
parent 0bd0d5571a
commit fb4a466321
1 changed files with 3 additions and 1 deletions

View File

@ -478,8 +478,10 @@ func handleAttachPod(f *cmdutil.Factory, c *client.Client, ns, name string, opts
opts.Client = c
opts.PodName = name
opts.Namespace = ns
// TODO: opts.Run sets opts.Err to nil, we need to find a better way
stderr := opts.Err
if err := opts.Run(); err != nil {
fmt.Fprintf(opts.Err, "Error attaching, falling back to logs: %v\n", err)
fmt.Fprintf(stderr, "Error attaching, falling back to logs: %v\n", err)
req, err := f.LogsForObject(pod, &api.PodLogOptions{Container: ctrName})
if err != nil {
return err