Skip to content

Commit ed71575

Browse files
committed
enhance: add latest_revision field to writing files in a workspace
This field implements an optimistic locking behavior in the workspace-provider. Signed-off-by: Donnie Adams <[email protected]>
1 parent bf1b000 commit ed71575

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/sdkserver/workspaces.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ type writeFileInWorkspaceRequest struct {
187187
FilePath string `json:"filePath"`
188188
Contents string `json:"contents"`
189189
CreateRevision *bool `json:"createRevision"`
190+
LatestRevision string `json:"latestRevision"`
190191
}
191192

192193
func (s *server) writeFileInWorkspace(w http.ResponseWriter, r *http.Request) {
@@ -208,8 +209,8 @@ func (s *server) writeFileInWorkspace(w http.ResponseWriter, r *http.Request) {
208209
prg,
209210
s.getServerToolsEnv(reqObject.Env),
210211
fmt.Sprintf(
211-
`{"workspace_id": "%s", "file_path": "%s", "body": "%s", "create_revision": %t}`,
212-
reqObject.ID, reqObject.FilePath, reqObject.Contents, reqObject.CreateRevision == nil || *reqObject.CreateRevision,
212+
`{"workspace_id": "%s", "file_path": "%s", "body": "%s", "create_revision": %t, "latest_revision": "%s"}`,
213+
reqObject.ID, reqObject.FilePath, reqObject.Contents, reqObject.CreateRevision == nil || *reqObject.CreateRevision, reqObject.LatestRevision,
213214
),
214215
)
215216
if err != nil {

0 commit comments

Comments
 (0)