mirror of https://github.com/containers/podman.git
Merge pull request #18372 from Luap99/save-stdout
windows: podman save allow the use of stdout
This commit is contained in:
commit
91da62d74c
|
@ -282,10 +282,19 @@ func (ir *ImageEngine) Save(ctx context.Context, nameOrID string, tags []string,
|
||||||
defer func() { _ = os.Remove(f.Name()) }()
|
defer func() { _ = os.Remove(f.Name()) }()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// This code was added to allow for opening stdout replacing
|
// This is ugly but I think the best we can do for now,
|
||||||
// os.Create(opts.Output) which was attempting to open the file
|
// on windows there is no /dev/stdout but the save command defaults to /dev/stdout.
|
||||||
// for read/write which fails on Darwin platforms
|
// The proper thing to do would be to pass an io.Writer down from the cli frontend
|
||||||
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue