From 028b28e406a787214bbcba727a17ae9709c6e4ac Mon Sep 17 00:00:00 2001 From: unclejack Date: Tue, 12 Aug 2014 19:20:59 +0300 Subject: [PATCH] pkg/ioutils: add WriteCloserWrapper Docker-DCO-1.1-Signed-off-by: Cristian Staretu (github: unclejack) --- ioutils/writers.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ioutils/writers.go b/ioutils/writers.go index de7bd02..c0b3608 100644 --- a/ioutils/writers.go +++ b/ioutils/writers.go @@ -21,3 +21,19 @@ func NopWriteCloser(w io.Writer) io.WriteCloser { type NopFlusher struct{} func (f *NopFlusher) Flush() {} + +type writeCloserWrapper struct { + io.Writer + closer func() error +} + +func (r *writeCloserWrapper) Close() error { + return r.closer() +} + +func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser { + return &writeCloserWrapper{ + Writer: r, + closer: closer, + } +}