Skip to content

[Refactor] simplify the stdout rewrite logic in image.Save #1940

Open
@Zheaoli

Description

@Zheaoli
          (below is more for discussion and see other reviewers' thought).

I think we should remove Output string from ImageSaveOptions. Functionally, it represents the same thing as Stdout io.Writer and having both might cause inconsistency and confusing, for example:

  • Even Output != "", we init Stdout = cmd.OutOrStdout() when creating ImageSaveOptions, and then change it after the file writer created (i.e., here).
  • Should a caller specify Output, or Stdout io.Writer?

If we remove Output and keep Stdout only:

  1. pkg/cmd side logic doesn't need to know where the writer comes from. It just writes content to it.
  2. On cmd side, we init opt.Stdout = cmd.OutOrStdout() if output == "" or create a file writer and use it as opt.Stdout (i.e., this pard of code).

Originally posted by @djdongjin in #1924 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions