Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit f6c3694

Browse files
committed
AcivityWriter
1 parent 174c866 commit f6c3694

File tree

3 files changed

+22
-38
lines changed

3 files changed

+22
-38
lines changed

cmd/coder/shell.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,16 @@ func runCommand(ctx context.Context, envName string, command string, args []stri
144144
stdin := process.Stdin()
145145
defer stdin.Close()
146146

147-
ap := &activity.Pusher{Source: "ssh", EnvID: env.ID, Client: entClient}
147+
ap := &activity.Pusher{Source: sshActivityName, EnvID: env.ID, Client: entClient}
148148
defer ap.Start()()
149149

150-
activity.Copy(ap, stdin, os.Stdin)
150+
wr := activity.Writer(ap, stdin)
151+
io.Copy(wr, os.Stdin)
151152
}()
152153
go io.Copy(os.Stdout, process.Stdout())
153154
go io.Copy(os.Stderr, process.Stderr())
154155

155156
return process.Wait()
156157
}
158+
159+
const sshActivityName = "ssh"

internal/activity/copy.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

internal/activity/writer.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package activity
2+
3+
import "io"
4+
5+
type activityWriter struct {
6+
p *Pusher
7+
wr io.Writer
8+
}
9+
10+
func (w *activityWriter) Write(p []byte) (n int, err error) {
11+
w.p.Push()
12+
return w.wr.Write(p)
13+
}
14+
15+
func Writer(p *Pusher, wr io.Writer) io.Writer {
16+
return &activityWriter{p: p, wr: wr}
17+
}

0 commit comments

Comments
 (0)