mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-17 08:46:52 +01:00
Extract the ssh debug commands into a transport neutral commands package (#1958)
Migrate commands from ssh into a transport neutral package - add golden tests validating that output remains unchanged - move commands to commands.go Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
cda3710d5a
commit
b426843f88
21 files changed
+2038
-978
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package commands
|
||||
|
||||
import "io"
|
||||
|
||||
// StringWriter is how a command talks back to whoever invoked it: one stream, which the
|
||||
// ssh surface points at its channel.
|
||||
type StringWriter interface {
|
||||
WriteLine(string) error
|
||||
Write(string) error
|
||||
WriteBytes([]byte) error
|
||||
GetWriter() io.Writer
|
||||
}
|
||||
|
||||
type stringWriter struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
||||
// NewStringWriter returns a StringWriter that writes to w.
|
||||
func NewStringWriter(w io.Writer) StringWriter {
|
||||
return &stringWriter{w: w}
|
||||
}
|
||||
|
||||
func (w *stringWriter) WriteLine(s string) error {
|
||||
return w.Write(s + "\n")
|
||||
}
|
||||
|
||||
func (w *stringWriter) Write(s string) error {
|
||||
_, err := w.w.Write([]byte(s))
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *stringWriter) WriteBytes(b []byte) error {
|
||||
_, err := w.w.Write(b)
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *stringWriter) GetWriter() io.Writer {
|
||||
return w.w
|
||||
}
|
||||
Reference in new issue
Block a user