chore: update protobuf to reuse file request (#21447)

**This is just the protobuf changes for the PR https://github.com/coder/coder/pull/21398**

Moved `UploadFileRequest` from `provisionerd.proto` -> `provisioner.proto`.

Renamed to `FileUpload` because it is now bi-directional.

This **is backwards compatible**. I tested it to confirm the payloads are identical.  Types were just renamed and moved around.

```golang
func TestTypeUpgrade(t *testing.T) {
	t.Parallel()

	x := &proto2.UploadFileRequest{
		Type: &proto2.UploadFileRequest_ChunkPiece{
			ChunkPiece: &proto.ChunkPiece{
				Data:         []byte("Hello World!"),
				FullDataHash: []byte("Foobar"),
				PieceIndex:   42,
			},
		},
	}

	data, err := protobuf.Marshal(x)
	require.NoError(t, err)

	// Exactly the same output
	// EhgKDEhlbGxvIFdvcmxkIRIGRm9vYmFyGCo= on `main`
	// EhgKDEhlbGxvIFdvcmxkIRIGRm9vYmFyGCo= on this branch
	fmt.Println(base64.StdEncoding.EncodeToString(data))
}
```


# What this does

This allows provisioner daemons to download files from `coderd`'s `files` table. This is used to send over cached module files and prevent the need of downloading these modules on each workspace build.
This commit is contained in:
Steven Masley
2026-01-09 11:23:32 -06:00
committed by GitHub
parent 89f4d60e7b
commit d2044c2ee9
12 changed files with 841 additions and 467 deletions
@@ -1433,7 +1433,7 @@ UploadFileStream:
}
switch typed := msg.Type.(type) {
case *proto.UploadFileRequest_DataUpload:
case *sdkproto.FileUpload_DataUpload:
if file != nil {
return xerrors.New("unexpected file upload while waiting for file completion")
}
@@ -1453,7 +1453,7 @@ UploadFileStream:
// This should never really happen in practice, but we handle it gracefully.
break UploadFileStream
}
case *proto.UploadFileRequest_ChunkPiece:
case *sdkproto.FileUpload_ChunkPiece:
if file == nil {
return xerrors.New("unexpected chunk piece while waiting for file upload")
}
@@ -1518,6 +1518,11 @@ UploadFileStream:
return nil
}
func (*server) DownloadFile(_ *proto.FileRequest, _ proto.DRPCProvisionerDaemon_DownloadFileStream) error {
// TODO implemented in follow up PR
panic("implement me")
}
// CompleteJob is triggered by a provision daemon to mark a provisioner job as completed.
func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob) (*proto.Empty, error) {
ctx, span := s.startTrace(ctx, tracing.FuncName())