containerd / containerd/nerdctl
[Refactor] simplify the stdout rewrite logic in image.Save
- Dominant language
- Go
- Stars
- 10.4k
- Forks
- 826
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 44
Description
(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 https://github.com/containerd/nerdctl/pull/1924#discussion_r1087419176_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.