mirror of
https://github.com/docker/compose.git
synced 2025-07-27 07:34:10 +02:00
Add functions to add the writer in the context
This commit is contained in:
parent
d0e48a25aa
commit
fe47237767
@ -59,6 +59,19 @@ type writer struct {
|
|||||||
mtx *sync.RWMutex
|
mtx *sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type writerKey struct{}
|
||||||
|
|
||||||
|
// WithContextWriter adds the writer to the context
|
||||||
|
func WithContextWriter(ctx context.Context, writer Writer) context.Context {
|
||||||
|
return context.WithValue(ctx, writerKey{}, writer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextWriter returns the writer from the context
|
||||||
|
func ContextWriter(ctx context.Context) Writer {
|
||||||
|
s, _ := ctx.Value(writerKey{}).(Writer)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
// NewWriter returns a new multi-progress writer
|
// NewWriter returns a new multi-progress writer
|
||||||
func NewWriter(out io.Writer) Writer {
|
func NewWriter(out io.Writer) Writer {
|
||||||
return &writer{
|
return &writer{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user