Skip to content

Commit

Permalink
Merge pull request #12495 from monstermunchkin/issues/12197-instance-…
Browse files Browse the repository at this point in the history
…exec-args

client: Use io.Writer for Stdout/Stderr in InstanceExecArgs
  • Loading branch information
tomponline authored Nov 17, 2023
2 parents 03bc41e + ce2aad5 commit 9565508
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 3 additions & 3 deletions client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,13 @@ type InstanceConsoleLogArgs struct {
// The InstanceExecArgs struct is used to pass additional options during instance exec.
type InstanceExecArgs struct {
// Standard input
Stdin io.ReadCloser
Stdin io.Reader

// Standard output
Stdout io.WriteCloser
Stdout io.Writer

// Standard error
Stderr io.WriteCloser
Stderr io.Writer

// Control message handler (window resize, signals, ...)
Control func(conn *websocket.Conn)
Expand Down
4 changes: 0 additions & 4 deletions client/lxd_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -1287,10 +1287,6 @@ func (r *ProtocolLXD) ExecInstance(instanceName string, exec api.InstanceExecPos
}

if fds["0"] != "" {
if args.Stdin != nil {
_ = args.Stdin.Close()
}

// Empty the stdin channel but don't block on it as
// stdin may be stuck in Read()
go func() {
Expand Down
8 changes: 4 additions & 4 deletions shared/ws/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func Mirror(conn *websocket.Conn, rwc io.ReadWriteCloser) (chan error, chan erro
return chRead, chWrite
}

// MirrorRead is a uni-directional mirror which replicates an io.ReadCloser to a websocket.
func MirrorRead(conn *websocket.Conn, rc io.ReadCloser) chan error {
// MirrorRead is a uni-directional mirror which replicates an io.Reader to a websocket.
func MirrorRead(conn *websocket.Conn, rc io.Reader) chan error {
chDone := make(chan error, 1)
if rc == nil {
close(chDone)
Expand All @@ -45,8 +45,8 @@ func MirrorRead(conn *websocket.Conn, rc io.ReadCloser) chan error {
return chDone
}

// MirrorWrite is a uni-directional mirror which replicates a websocket to an io.WriteCloser.
func MirrorWrite(conn *websocket.Conn, wc io.WriteCloser) chan error {
// MirrorWrite is a uni-directional mirror which replicates a websocket to an io.Writer.
func MirrorWrite(conn *websocket.Conn, wc io.Writer) chan error {
chDone := make(chan error, 1)
if wc == nil {
close(chDone)
Expand Down

0 comments on commit 9565508

Please sign in to comment.