Skip to content
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

windows: podman save allow the use of stdout #18372

Merged
merged 1 commit into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pkg/domain/infra/tunnel/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,19 @@ func (ir *ImageEngine) Save(ctx context.Context, nameOrID string, tags []string,
defer func() { _ = os.Remove(f.Name()) }()
}
default:
// This code was added to allow for opening stdout replacing
// os.Create(opts.Output) which was attempting to open the file
// for read/write which fails on Darwin platforms
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
// This is ugly but I think the best we can do for now,
// on windows there is no /dev/stdout but the save command defaults to /dev/stdout.
// The proper thing to do would be to pass an io.Writer down from the cli frontend
// but since the local save API does not support an io.Writer this is impossible.
// I reported it a while ago in https://github.com/containers/common/issues/1275
if opts.Output == "/dev/stdout" {
f = os.Stdout
} else {
// This code was added to allow for opening stdout replacing
// os.Create(opts.Output) which was attempting to open the file
// for read/write which fails on Darwin platforms
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
}
}
if err != nil {
return err
Expand Down