@@ -38,22 +38,6 @@ func sandboxRef(id string) *sandboxv1.SandboxRef {
3838 }
3939}
4040
41- // commandRef wraps a command id in the depot.sandbox.v1 selector oneof.
42- // Used by AttachCommand / KillCommand callers.
43- func commandRef (id string ) * sandboxv1.SandboxCommandExecutionRef {
44- return & sandboxv1.SandboxCommandExecutionRef {
45- Selector : & sandboxv1.SandboxCommandExecutionRef_Id {Id : id },
46- }
47- }
48-
49- // snapshotRef wraps a snapshot id in the depot.sandbox.v1 selector oneof.
50- // Used by GetSnapshot / DeleteSnapshot.
51- func snapshotRef (id string ) * sandboxv1.SnapshotRef {
52- return & sandboxv1.SnapshotRef {
53- Selector : & sandboxv1.SnapshotRef_Id {Id : id },
54- }
55- }
56-
5741// consumeCommandEventStream drains a depot.sandbox.v1 CommandEvent stream
5842// into stdout/stderr and returns the final exit code from Finished. The
5943// stream shape mirrors RunCommand / RunCommandPipe / AttachCommand /
@@ -63,19 +47,9 @@ func snapshotRef(id string) *sandboxv1.SnapshotRef {
6347// see the gap; the stream continues afterward. Error frames are surfaced the
6448// same way and do not abort the loop (the server is signalling partial
6549// degradation, not a fatal end — Connect transport errors are the fatal path).
66- // detachedMode flags a RunCommand stream that the server will close after
67- // Started — no Finished event will arrive, and that's not an error.
68- type detachedMode bool
69-
70- const (
71- streamUntilFinished detachedMode = false
72- streamUntilStarted detachedMode = true
73- )
74-
7550func consumeCommandEventStream (
7651 stream * connect.ServerStreamForClient [sandboxv1.SandboxCommandExecutionEvent ],
7752 stdout , stderr io.Writer ,
78- mode detachedMode ,
7953) (exitCode int32 , err error ) {
8054 defer func () { _ = stream .Close () }()
8155 for stream .Receive () {
@@ -109,13 +83,5 @@ func consumeCommandEventStream(
10983 if err := stream .Err (); err != nil && ! errors .Is (err , io .EOF ) {
11084 return 0 , fmt .Errorf ("command stream: %w" , err )
11185 }
112- // In detached mode the server hangs up after Started — no Finished is
113- // expected and "exit 0, no error" is the right success signal. For
114- // non-detached commands, end-of-stream without Finished means the server
115- // disconnected mid-run; surface that as an error so callers don't conflate
116- // a clean disconnect with a real exit-0 completion.
117- if mode == streamUntilStarted {
118- return 0 , nil
119- }
12086 return 0 , fmt .Errorf ("command stream closed without Finished event" )
12187}
0 commit comments