Skip to content

Commit 91da62d

Browse files
Merge pull request #18372 from Luap99/save-stdout
windows: podman save allow the use of stdout
2 parents 3f5f906 + aca9936 commit 91da62d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pkg/domain/infra/tunnel/images.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,19 @@ func (ir *ImageEngine) Save(ctx context.Context, nameOrID string, tags []string,
282282
defer func() { _ = os.Remove(f.Name()) }()
283283
}
284284
default:
285-
// This code was added to allow for opening stdout replacing
286-
// os.Create(opts.Output) which was attempting to open the file
287-
// for read/write which fails on Darwin platforms
288-
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
285+
// This is ugly but I think the best we can do for now,
286+
// on windows there is no /dev/stdout but the save command defaults to /dev/stdout.
287+
// The proper thing to do would be to pass an io.Writer down from the cli frontend
288+
// but since the local save API does not support an io.Writer this is impossible.
289+
// I reported it a while ago in https://github.com/containers/common/issues/1275
290+
if opts.Output == "/dev/stdout" {
291+
f = os.Stdout
292+
} else {
293+
// This code was added to allow for opening stdout replacing
294+
// os.Create(opts.Output) which was attempting to open the file
295+
// for read/write which fails on Darwin platforms
296+
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
297+
}
289298
}
290299
if err != nil {
291300
return err

0 commit comments

Comments
 (0)