From cf37b661dd227efff5271c1b5fcc613dc21ef5a7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 10 Jan 2025 14:17:28 +0100 Subject: [PATCH 1/2] pkg/ioutils: deprecate NopWriter It's not used, and users can use io.Discard instead. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 7fa3c553e79f8c18114b31b5e129dfd9260737bf) Signed-off-by: Sebastiaan van Stijn --- pkg/ioutils/writers.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/ioutils/writers.go b/pkg/ioutils/writers.go index ec6604ae66..ad0b3f1639 100644 --- a/pkg/ioutils/writers.go +++ b/pkg/ioutils/writers.go @@ -6,6 +6,8 @@ import ( ) // NopWriter represents a type which write operation is nop. +// +// Deprecated: use [io.Discard] instead. This type will be removed in the next release. type NopWriter struct{} func (*NopWriter) Write(buf []byte) (int, error) { From 8a2fd51c84e9ce58b7dec29e1b86844ac4b5b3a6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 10 Jan 2025 14:18:41 +0100 Subject: [PATCH 2/2] pkg/ioutils: deprecate NopWriteCloser It was only used internally, and has no external consumers; deprecate it to be removed in the next release. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 3faa170371942f9ede2ba6b52deb3524e25ac002) Signed-off-by: Sebastiaan van Stijn --- container/stream/streams.go | 8 +++++++- pkg/ioutils/writers.go | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/container/stream/streams.go b/container/stream/streams.go index b64e3a3969..a5d8d390ad 100644 --- a/container/stream/streams.go +++ b/container/stream/streams.go @@ -87,9 +87,15 @@ func (c *Config) NewInputPipes() { // NewNopInputPipe creates a new input pipe that will silently drop all messages in the input. func (c *Config) NewNopInputPipe() { - c.stdinPipe = ioutils.NopWriteCloser(io.Discard) + c.stdinPipe = &nopWriteCloser{io.Discard} } +type nopWriteCloser struct { + io.Writer +} + +func (w *nopWriteCloser) Close() error { return nil } + // CloseStreams ensures that the configured streams are properly closed. func (c *Config) CloseStreams() error { var errs []string diff --git a/pkg/ioutils/writers.go b/pkg/ioutils/writers.go index ad0b3f1639..aec8b4c03e 100644 --- a/pkg/ioutils/writers.go +++ b/pkg/ioutils/writers.go @@ -21,6 +21,8 @@ type nopWriteCloser struct { func (w *nopWriteCloser) Close() error { return nil } // NopWriteCloser returns a nopWriteCloser. +// +// Deprecated: This function is no longer used and will be removed in the next release. func NopWriteCloser(w io.Writer) io.WriteCloser { return &nopWriteCloser{w} }